home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Utilities / FWCalendar / FWCalendar.rexx < prev    next >
OS/2 REXX Batch file  |  2001-06-09  |  279KB  |  7,322 lines

  1. /*
  2.   FWCalendar.rexx Macro
  3.   Creates calendars on FinalWriter v 4.x (SoftWood) & PageStream v 3.x
  4.   $VER: FWCalendar.rexx v4.13 (3 Jun 2001)
  5.   ©Ron Goertz (goertz@earthlink.net)
  6. */
  7. options results
  8. options failat 11
  9. signal on syntax
  10. Numeric Digits 14
  11.  
  12. parse source . . . FullCallPath . CallHost
  13. CallHost = strip(CallHost)
  14. ScriptDir = PathPart(FullCallPath)
  15.  
  16. CurrentDir = upper(Pragma('D'))
  17. if right(CurrentDir, 1) ~= ':' then CurrentDir = CurrentDir'/'
  18.  
  19. call AddLibraries
  20. if ErrorCount > 0 then call Cleanup
  21.  
  22. address value DetermineHost()
  23. call GetSetupInfo
  24.  
  25. if CalType < 3 then do
  26.   if CalType == 1 then do
  27.     PrevMonth = Month - 1
  28.       if PrevMonth = 0 then do
  29.       PrevMonth = 12
  30.       PrevYear = Year - 1
  31.     end
  32.     else PrevYear = Year
  33.  
  34.     NextMonth = Month + 1
  35.     if NextMonth = 13 then do
  36.       NextMonth = 1
  37.       NextYear = Year + 1
  38.     end
  39.     else NextYear = Year
  40.  
  41.     Calendar = Month.Month' 'EnteredYear
  42.  
  43.     Mn = right(Month, 2, '0')
  44.     if DataType(Month) == 'NUM' then call setclip('FWC_CalMonth', Month)
  45.     if DataType(EnteredYear) == 'NUM' then call setclip('FWC_CalYear', EnteredYear)
  46.  
  47.     call SetVariables
  48.     call MonthlyCalendar
  49.   end
  50.   else do
  51.     call SetVariables
  52.     StartMonth = Month
  53.     do MonthNumber = StartMonth to EndMonth
  54.       if MonthNumber > 12 then do
  55.         Month = MonthNumber - 12
  56.         Year = EnteredYear + 1
  57.       end
  58.       else do
  59.         Month = MonthNumber
  60.         Year = EnteredYear
  61.       end
  62.  
  63.       PrevMonth = Month - 1
  64.       if PrevMonth = 0 then do
  65.         PrevMonth = 12
  66.         PrevYear = Year - 1
  67.       end
  68.       else PrevYear = Year
  69.  
  70.       NextMonth = Month + 1
  71.       if NextMonth = 13 then do
  72.         NextMonth = 1
  73.         NextYear = Year + 1
  74.       end
  75.       else NextYear = Year
  76.  
  77.       Calendar = Month.Month' 'EnteredYear
  78.       Mn = right(Month, 2, '0')
  79.  
  80.       call MonthlyCalendar
  81.       if MonthNumber ~= EndMonth then do
  82.         if DoHide == 1 then do
  83.           REVEALWINDOW ALL
  84.           DISPLAY PAGE NEXT
  85.           HIDEWINDOW
  86.         end
  87.         else DISPLAY PAGE NEXT
  88.       end
  89.     end
  90.   end
  91. end
  92. else do
  93.   call SetVariables
  94.   Calendar = EnteredYear
  95.   call YearlyCalendar
  96. end
  97.  
  98. call Cleanup
  99. exit
  100.  
  101. /***//*** YearlyCalendar ***/
  102. YearlyCalendar:
  103.   call MiniCalPreCalc(FYMiniCal, MiniCalWidth)
  104.  
  105.   Year = EnteredYear
  106.   interpret 'StartYear = Day.'DateInfo('W', Year'0101', 'S')
  107.  
  108.   YearOffset = 7 - StartYear
  109.   if YearOffset == 7 then YearOffset = 0
  110.  
  111.   if (Year//4 == 0 & Year//100 > 0) | Year//400 == 0 then MonthLength.2 = 29
  112.   else MonthLength.2 = 28
  113.  
  114.   CalTop = Margin.Top
  115.   do r = 0 to 3
  116.     Margin.Top = CalTop + r * (7*Height.FYMiniCal + MiniCalSpacing)
  117.     do c = 0 to 2
  118.       Month = r * 3 + c + 1
  119.       Mn = right(Month, 2, '0')
  120.       TempDate = Year''Mn'01'
  121.       if (Year//4 == 0 & Year//100 > 0) | Year//400 == 0 Then MonthLength.2 = 29
  122.       interpret 'StartDate = Day.'DateInfo('W', TempDate, 'S')
  123.       call DrawMiniCal(0, MiniCalWidth, FYMiniCal)
  124.     end
  125.   end
  126.  
  127.   if DoCopyright == 1 then call RightText(PrintText(0, CalTop + 28 * Height.FYMiniCal + 3 * MiniCalSpacing, 4pt, 'N', Black$, 100, CNotice), Margin.Left + PrintWidth)
  128.  
  129.   return
  130. /**/
  131.  
  132. /***//*** MonthlyCalendar ***/
  133. MonthlyCalendar:
  134.   if (DoSunRise ~= 0) | (DoSunSet ~= 0) then do
  135.     StartDST = DateInfo('I', Year'04'right(CalculateDate(4, 'Monday', 7), 2, '0'), 'S') /* First Sunday in April */
  136.     EndDST   = DateInfo('I', Year'10'CalculateDate(10, 'Friday', 31), 'S') /* Last Sunday in October */
  137.   end
  138.  
  139.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  140.  
  141.   TempDate  = Year''Mn'01'
  142.   IDay      = DateInfo('I', TempDate, 'S') - 1
  143.   interpret 'StartYear = Day.'DateInfo('W', Year'0101', 'S')
  144.  
  145.   YearOffset = 7 - StartYear
  146.   if YearOffset == 7 then YearOffset = 0
  147.  
  148.   if (Year//4 == 0 & Year//100 > 0) | Year//400 == 0 Then do
  149.     LeapYear = 1
  150.     MonthLength.2 = 29
  151.   end
  152.   else do
  153.     LeapYear = 0
  154.     MonthLength.2 = 28
  155.   end
  156.  
  157.   if (PrevYear//4 == 0 & PrevYear//100 > 0) | PrevYear//400 == 0 Then PrevLeapYear = 1
  158.   else PrevLeapYear = 0
  159.  
  160.   interpret 'StartDate = Day.'DateInfo('W', TempDate, 'S')
  161.   if (DoHighlights == 1) | (DoImages == 1) then call SetHighLights
  162.   if DoPhases ~= '' then call GetPhases(Year, Month)
  163.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  164.  
  165.   /* No other objects should be drawn overlapping 0,0 */
  166.   PrefsString = 'FWC'TempDate''PrefsFile
  167.   StringCount = trunc(length(PrefsString) / 25)
  168.   NextString = 0
  169.  
  170.   do i = StringCount to 0 by -1
  171.     PrintString = substr(PrefsString, (i * 25) + 1, 25)
  172.     if NextString ~= 0 then PrintString = PrintString'|'NextString'|'
  173.     NextString = PrintText(0, 0, 4pt, 'N', White$, 100, PrintString)
  174.   end
  175.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  176.  
  177. /***//*** Draw dates and optional highlights ***/
  178.   Day             = - StartDate
  179.   GridLineTop.    = CalTop
  180.   GridLineBottom. = CalTop + BoxHeight*5
  181.   GridLineLeft.   = Margin.Left
  182.   GridLineRight.  = CalRight
  183.   GridLineRight.6 = 0
  184.   SplitDay.       = 0
  185.   MaxRow          = 0
  186.  
  187.   if (DoTopExtraWk ~= 1) & (trunc((StartDate + MonthLength.Month)/7) == 5) then do
  188.     do i = 1 to (StartDate + MonthLength.Month)//7
  189.       SplitDay = MonthLength.Month + 1 - i
  190.       SplitDay.SplitDay = 1
  191.       SplitDay = MonthLength.Month + 1 - i - 7
  192.       SplitDay.SplitDay = 1
  193.     end
  194.   end
  195.  
  196.   Width.WidthOfDate1 = GetFontWidth(Date, 'N', '1')
  197.   Width.WidthOfDate8 = GetFontWidth(Date, 'N', '8')
  198.  
  199.   if (DoRandom ~= '') & (exists(ScriptDir'FWCRandom.txt')) then do
  200.     UsedRandoms = ''
  201.     RandomFile = ReadFile(ScriptDir'FWCRandom.txt')
  202.     call openv('RandomFile')
  203.     RandomCount = length(RandomFile) - length(compress(RandomFile, '|'))
  204.   end
  205.   else DoRandom = 0
  206.  
  207.   if (DoHistory ~= '') & (exists(ScriptDir'FWCHistory/'right(Month, 2, '0'))) then do
  208.     UsedRandoms = ''
  209.     RandomFile = ReadFile(ScriptDir'FWCHistory/'right(Month, 2, '0'))
  210.   end
  211.   else DoHistory = 0
  212.  
  213.   if Day + 1 + WeekdayCount < 1 then Day = Day + 7
  214.   Do CRow = 0 to 5
  215.     CurrentRow = CRow
  216.     if (CRow == 5) & (DoTopExtraWk == 1) then CurrentRow = 0
  217.     BoxTop  = CalTop + BoxHeight*CurrentRow
  218.     if (CRow == 5) & (DoTopExtraWk ~= 1) then BoxTop = CalTop + BoxHeight*4.5
  219.     if CRow ~= 5 then MaxRow = MaxRow + 1
  220.  
  221.     Do CurrentColumn = 0 to 6
  222.       Day = Day + 1
  223.       if CurrentColumn <= WeekdayCount then do
  224.         BackgroundColor = Background.Standard
  225.         if SplitDay.Day == 1 then BHeight = BoxHeight/2
  226.         else BHeight = BoxHeight
  227.         JulianDay = IDay + Day
  228.         BoxLeft = Margin.Left + BoxWidth * CurrentColumn
  229.         PrintDay = ''
  230.  
  231.         /* Days for previous & next months */
  232.         If ((Day < 1) | (Day > MonthLength.Month)) then do
  233.  
  234.           /* Previous month */
  235.           if Day < 1 then do
  236.             if DoExtended then PrintDay = MonthLength.PrevMonth + Day
  237.             GridLineTop.CurrentColumn = CalTop + BoxHeight
  238.             GridLineLeft.0 = Margin.Left + BoxWidth * (CurrentColumn + 1)
  239.           end
  240.  
  241.           /* Next month */
  242.           else do
  243.             if DoExtended then PrintDay = Day - MonthLength.Month
  244.             interpret 'GridLineBottom.'CurrentColumn+1' = 'CalTop + BoxHeight*4
  245.             CalRow = CurrentRow + 1
  246.             if GridLineRight.CalRow == CalRight then GridLineRight.CalRow = Margin.Left + BoxWidth * CurrentColumn
  247.           end
  248.  
  249.           if DoExtended then do
  250.             if (CurrentColumn = Day.Sunday | CurrentColumn = Day.Saturday) & (Background.Weekend ~= '<'Clear$'>') then BackgroundColor = Background.Weekend
  251.             DayType = 'Extended'
  252.             GridColor = Line.Extended
  253.             if BackgroundColor ~= '<'Clear$'>' then TextColor = AltColor.Extended
  254.             else TextColor = Color.Extended
  255.           end
  256.           else BackgroundColor = '<'Clear$'>'
  257.         end
  258.  
  259.         /* Days for current month */
  260.         else do
  261.           if CRow ~= CurrentRow then do
  262.             GridLineTop.CurrentColumn = CalTop
  263.             interpret 'GridLineTop.'CurrentColumn+1' = 'CalTop
  264.             GridLineRight.6 = Margin.Left + BoxWidth * (CurrentColumn + 1)
  265.           end
  266.  
  267.           if (CurrentColumn = Day.Sunday | CurrentColumn = Day.Saturday) & (Background.Weekend ~= '<'Clear$'>') then BackgroundColor = Background.Weekend
  268.  
  269.           /* Print Highlight */
  270.           if Highlight.Month.Day ~= '' & DoHighlights == 1 then do
  271.             if TopOption ~= 0 then Highlight.Month.Day = '//'Highlight.Month.Day
  272.             DailyHLCount = 0
  273.             SearchPos    = 1
  274.             Found        = 1
  275.             do until Found == 0
  276.               Found = pos('//', Highlight.Month.Day, SearchPos)
  277.               if Found > 0 then do
  278.                 HighlightText = substr(Highlight.Month.Day, SearchPos, Found - SearchPos)
  279.                 SearchPos = Found + 2
  280.               end
  281.               else HighlightText = substr(Highlight.Month.Day, SearchPos)
  282.  
  283.               ColorMarker = pos('00'x, HighlightText)
  284.               if ColorMarker > 0 then do
  285.                 TextColor = left(HighlightText, ColorMarker - 1)
  286.                 HighlightText = substr(Highlighttext, ColorMarker + 1)
  287.               end
  288.               else TextColor = ''
  289.  
  290.               /* Draw background colors for highlight days */
  291.               if (right(HighlightText, 1) == '#') & (Background.HighlightH ~= '<'Clear$'>') then do
  292.                 BackgroundColor = Background.HighlightH
  293.                 if (TextColor == '') | (TextColor == '<'Clear$'>') then do
  294.                   if (BackgroundColor ~= White$) then TextColor = AltColor.HighlightH
  295.                   else TextColor = Color.HighlightH
  296.                 end
  297.               end
  298.               else if Background.Highlight ~= '<'Clear$'>' then do
  299.                 BackgroundColor = Background.Highlight
  300.                 if (TextColor == '') | (TextColor == '<'Clear$'>') then do
  301.                   if (BackgroundColor ~= White$) then TextColor = AltColor.Highlight
  302.                   else TextColor = Color.Highlight
  303.                 end
  304.               end
  305.  
  306.               if (TextColor == '') | (TextColor == '<'Clear$'>') then do
  307.                 if right(HighlightText, 1) == '#' then TextColor = Color.HighlightH
  308.                 else TextColor = Color.Highlight
  309.               end
  310.  
  311.               if DoDateBox == 1 then HighlightOffset = CurveOffset + 1.25 * DateOffset + 2 * Width.WidthOfDate8
  312.               else do
  313.                 Select
  314.                   when Day < 10 then HighlightOffset = Width.WidthOfDate1 / 2 + Width.WidthOfDate8
  315.                   when Day < 20 then HighlightOffset = 1.5 * Width.WidthOfDate1 + Width.WidthOfDate8
  316.                   otherwise HighlightOffset = Width.WidthOfDate1 / 2 + 2 * Width.WidthOfDate8
  317.                 end
  318.               end
  319.  
  320.               call PrintHighlight(compress(HighlightText, '#'), 'Highlight')
  321.  
  322.               DailyHLCount = DailyHLCount + 1
  323.             end
  324.           end
  325.           else do
  326.             if DoDailyColors == 1 then do
  327.               Select
  328.                 when CurrentColumn == Day.Sunday then TextColor = Color.Sunday
  329.                 when CurrentColumn == Day.Monday then TextColor = Color.Monday
  330.                 when CurrentColumn == Day.Tuesday then TextColor = Color.Tuesday
  331.                 when CurrentColumn == Day.Wednesday then TextColor = Color.Wednesday
  332.                 when CurrentColumn == Day.Thursday then TextColor = Color.Thursday
  333.                 when CurrentColumn == Day.Friday then TextColor = Color.Friday
  334.                 when CurrentColumn == Day.Saturday then TextColor = Color.Saturday
  335.               end
  336.             end
  337.             else if BackgroundColor ~= '<'Clear$'>' then TextColor = AltColor.Date
  338.             else TextColor = Color.Date
  339.           end
  340.  
  341.           if DoMatchColors ~= 1 then do
  342.             if DoDailyColors == 1 then do
  343.               Select
  344.                 when CurrentColumn == Day.Sunday then TextColor = Color.Sunday
  345.                 when CurrentColumn == Day.Monday then TextColor = Color.Monday
  346.                 when CurrentColumn == Day.Tuesday then TextColor = Color.Tuesday
  347.                 when CurrentColumn == Day.Wednesday then TextColor = Color.Wednesday
  348.                 when CurrentColumn == Day.Thursday then TextColor = Color.Thursday
  349.                 when CurrentColumn == Day.Friday then TextColor = Color.Friday
  350.                 when CurrentColumn == Day.Saturday then TextColor = Color.Saturday
  351.               end
  352.             end
  353.             else if BackgroundColor ~= '<'Clear$'>' then TextColor = AltColor.Date
  354.             else TextColor = Color.Date
  355.           end
  356.  
  357.           /* Print Day */
  358.           DayType   = 'Normal'
  359.           PrintDay  = Day
  360.           GridColor = Line.Grid
  361.         end
  362.  
  363.         if PrintDay ~= '' then do
  364.           if DoDateBox == 1 then do
  365.             if PrintDay < 10 then LeftEdge = BoxLeft + CurveOffset + Width.WidthOfDate8
  366.             else LeftEdge = BoxLeft + CurveOffset
  367.           end
  368.           else LeftEdge = BoxLeft + CurveOffset
  369.           DayID = PrintText(LeftEdge, BoxTop, Date, 'N', TextColor, Width.Date, PrintDay)
  370.           if DoDateBox == 1 then call BoxDate(TextColor)
  371.           if CRadius ~= 0 then
  372.             call DrawBox(BoxLeft, BoxTop, BoxWidth, BHeight, 'HL', GridColor, 0, , (DayType == 'Extended'), CRadius)
  373.           call DoOptions
  374.         end
  375.  
  376.         if BackgroundColor ~= '<'Clear$'>' then
  377.           call DrawBox(BoxLeft, BoxTop, BoxWidth, BHeight, 0, , 1, BackgroundColor, 1, CRadius)
  378.         if UpdateBusy(Req, 1) == -1 then call Cleanup
  379.  
  380.         if (CRow == 5) & (Day == MonthLength.Month) then leave CRow
  381.       end
  382.     end
  383. /*
  384.     if DaysInRow = 0 then do
  385.       if CRow = 0 then do
  386.         GridLineTop.    = CalTop
  387.         GridLineBottom. = CalTop + BoxHeight*5
  388.         GridLineLeft.   = Margin.Left
  389.         GridLineRight.  = CalRight
  390.         GridLineRight.6 = 0
  391.         SplitDay.       = 0
  392.         MaxRow          = 0
  393.         CRow            = CRow - 1
  394.       end
  395.     end
  396. */
  397.     if Day >= MonthLength.Month then leave
  398.   end
  399.   call closev('RandomFile')
  400. /**/
  401.  
  402. /***//*** Draw grids ***/
  403.   LowRow = CRow
  404.   if LowRow = 3 then GridLineBottom. = CalTop + BoxHeight*4
  405.  
  406.   /* Draw note box */
  407.   drop TopNoteLeft
  408.   drop TopNoteRight
  409.   drop BottomNoteLeft
  410.   drop BottomNoteRight
  411.   if DoNoteBox then do
  412.     PrevTop = CalTop
  413.     PrevBottom = GridLineBottom.
  414.     do i = 0 to WeekdayCount + 1
  415.       if GridLineTop.i > PrevTop then TopNoteLeft = max(i - 1, 0)
  416.       if GridLineTop.i < PrevTop then TopNoteRight = i
  417.       PrevTop = GridLineTop.i
  418.     end
  419.     do i = 0 to WeekdayCount + 1
  420.       if GridLineBottom.i < PrevBottom then BottomNoteLeft = max(i - 1, 0)
  421.       if GridLineBottom.i > PrevBottom then BottomNoteRight = i
  422.       PrevBottom = GridLineBottom.i
  423.     end
  424.  
  425.     if (symbol('TopNoteLeft') == 'LIT') & (symbol('TopNoteRight') == 'LIT') then do
  426.       TopNoteleft = 0
  427.       TopNoteRight = 0
  428.     end
  429.  
  430.     if (symbol('BottomNoteLeft') == 'LIT') & (symbol('BottomNoteRight') == 'LIT') then do
  431.       BottomNoteleft = 0
  432.       BottomNoteRight = 0
  433.     end
  434.     if (symbol('BottomNoteLeft') == 'VAR') & (symbol('BottomNoteRight') == 'LIT') then BottomNoteRight = WeekdayCount + 1
  435.  
  436.     if TopNoteRight ~= TopNoteLeft then do
  437.       LeftEdge = Margin.Left + BoxWidth*TopNoteLeft
  438.       RightEdge = Margin.Left + BoxWidth*TopNoteRight
  439.       if CornerRadius == 0 then do
  440.         call DrawLine(LeftEdge, CalTop, RightEdge, CalTop, 'HL', Line.NoteBox)
  441.         if TopNoteLeft == 0 then call DrawLine(Margin.Left, CalTop, Margin.Left, GridLineTop.0, 'HL', Line.NoteBox)
  442.       end
  443.       else call DrawBox(LeftEdge, CalTop, RightEdge - LeftEdge, BoxHeight, 'HL', Line.NoteBox, 0, , 1, CRadius)
  444.       if Background.NoteBox ~= '<'Clear$'>' then
  445.         call DrawBox(LeftEdge, CalTop, RightEdge - LeftEdge, BoxHeight, 0, , 1, Background.NoteBox, 1, CRadius)
  446.       call PrintText(LeftEdge + CurveOffset, CalTop, Date, 'N', Color.NoteBox, Width.Date, Note$':')
  447.     end
  448.  
  449.     if BottomNoteRight ~= BottomNoteLeft then do
  450.       LeftEdge = Margin.Left + BoxWidth*BottomNoteLeft
  451.       RightEdge = Margin.Left + BoxWidth*BottomNoteRight
  452.       if CornerRadius == 0 then do
  453.         call DrawLine(LeftEdge, GridLineBottom.BottomNoteLeft, RightEdge, GridLineBottom.BottomNoteLeft, 'HL', Line.NoteBox)
  454.         call DrawLine(RightEdge, GridLineBottom.BottomNoteLeft, RightEdge, GridLineBottom.BottomNoteRight, 'HL', Line.NoteBox)
  455.       end
  456.       else call DrawBox(LeftEdge, GridLineBottom.BottomNoteRight, RightEdge - LeftEdge, BoxHeight, 'HL', Line.NoteBox, 0, , 1, CRadius)
  457.       if Background.NoteBox ~= '<'Clear$'>' then
  458.         call DrawBox(LeftEdge, GridLineBottom.BottomNoteRight, RightEdge - LeftEdge, BoxHeight, 0, , 1, Background.NoteBox, 1, CRadius)
  459.       call PrintText(LeftEdge + CurveOffset, GridLineBottom.BottomNoteRight, Date, 'N', Color.NoteBox, Width.Date, Note$':')
  460.     end
  461.   end
  462.  
  463.   if CornerRadius == 0 then do
  464.     /* Draw vertical grid */
  465.     do i = 0 to WeekdayCount + 1
  466.       LeftEdge = Margin.Left + BoxWidth*i
  467.       if DoExtended then do
  468.         if GridLineTop.i > CalTop then
  469.           call DrawLine(LeftEdge, CalTop, LeftEdge, GridLineTop.i, 'HL', Line.Extended)
  470.         if GridLineBottom.i < GridLineBottom.8 then
  471.           call DrawLine(LeftEdge, GridLineBottom.i, LeftEdge, GridLineBottom.8, 'HL', Line.Extended)
  472.       end
  473.       call DrawLine(LeftEdge, GridLineTop.i, LeftEdge, GridLineBottom.i, 'HL', Line.Grid)
  474.     end
  475.  
  476.     /* Draw horizontal grid */
  477.     do i = 0 to min(LowRow + 1, 5)
  478.       TopEdge = CalTop + BoxHeight * i
  479.       if DoExtended then do
  480.         if GridLineLeft.i > Margin.Left then
  481.           call DrawLine(Margin.Left, TopEdge, GridLineLeft.i, TopEdge, 'HL', Line.Extended)
  482.         if GridLineRight.i < CalRight then
  483.           call DrawLine(GridLineRight.i, TopEdge, CalRight, TopEdge, 'HL', Line.Extended)
  484.       end
  485.       call DrawLine(GridLineLeft.i, TopEdge, GridLineRight.i, TopEdge, 'HL', Line.Grid)
  486.     end
  487.  
  488.     if (trunc((StartDate + MonthLength.Month)/7) == 5) & (DoTopExtraWk == 0) & (CRow == 6) then
  489.       call DrawLine(Margin.Left, CalTop + BoxHeight * 4.5, Margin.Left + BoxWidth * ((StartDate + MonthLength.Month)//7), CalTop + BoxHeight * 4.5, 'HL', Line.Grid)
  490.  
  491.     if GridLineRight.6 ~= 0 then call DrawLine(Margin.Left, CalTop, GridLineRight.6, CalTop, 'HL', Line.Grid)
  492.   end
  493.  
  494.   if CalendarBorder ~= 0 then
  495.     call DrawBox(Margin.Left - CalendarBorder, CalTop - CalendarBorder, PrintWidth + 2 * CalendarBorder, MaxRow * BoxHeight + 2 * CalendarBorder, 'HL', Line.CalBorder, 0, , 1, CRadius)
  496.  
  497.   if CalendarShadow ~= 0 then do
  498.     if ShadowType == 'P' then do
  499.       call DrawBox(Margin.Left + PrintWidth + CalendarBorder, CalTop - CalendarBorder + CalendarShadow, CalendarShadow, MaxRow * BoxHeight + 2 * CalendarBorder, 0, , 1, Background.CalShadow, 1, 0)
  500.       call DrawBox(Margin.Left - CalendarBorder + CalendarShadow, CalTop + MaxRow * BoxHeight + CalendarBorder, PrintWidth + 2 * CalendarBorder, CalendarShadow, 0, , 1, Background.CalShadow, 1, 0)
  501.     end
  502.     else call DrawBox(Margin.Left - CalendarBorder + CalendarShadow, CalTop - CalendarBorder + CalendarShadow, PrintWidth + 2 * CalendarBorder, MaxRow * BoxHeight + 2 * CalendarBorder, 0, , 1, Background.CalShadow, 1, CRadius)
  503.   end
  504. /**/
  505.  
  506. /***//*** Draw headers & minicals ***/
  507.   /* Create month/year header */
  508.   if Header$ ~= '' then do
  509.     Text.Top = Margin.Top + TextArea * HeaderLoc
  510.     call CenterText(PrintText(Margin.Left, Text.Top , Header, 'N', Color.Header, Width.Header, BuildString(Header$, HeaderVars)), Margin.Left + PrintWidth/2, .9 * (PrintWidth - DoMiniCals * (2 * MiniCalWidth)), 0)
  511.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  512.   end
  513.  
  514.   if SubHeader$ ~= '' then do
  515.     Text.Top = Margin.Top + TextArea * SubHeaderLoc
  516.     call CenterText(PrintText(Margin.Left, Text.Top , SubHeader, 'N', Color.SubHeader, Width.SubHeader, BuildString(SubHeader$, SubHeaderVars)), Margin.Left + PrintWidth/2, .9 * (PrintWidth - DoMiniCals * (2 * MiniCalWidth)), 0)
  517.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  518.   end
  519.  
  520.   /* Create weekday titles */
  521.   Text.Top = CalTop - (Height.Weekday * 1.15) - CalendarBorder
  522.   Do i = 0 to WeekdayCount
  523.     WeekdayID.i = PrintText(1, Text.Top, Weekday, 'N', Color.Weekday, Width.Weekday, Day.i)
  524.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  525.   End
  526.  
  527.   /* Position weekday titles */
  528.   MaxWidth = GetMaxWidth('WeekdayID', WeekdayCount)
  529.   if MaxWidth == 0 then MaxWidth = BoxWidth
  530.  
  531.   Do i = 0 to WeekdayCount
  532.     call CenterText(WeekdayID.i, Margin.Left + (i + .5) * BoxWidth, 0, .9 * min(1, BoxWidth/MaxWidth))
  533.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  534.   end
  535.  
  536.   if DoMiniCals = 1 then do
  537.     call MiniCalPreCalc(MiniCal, MiniCalWidth)
  538.     call DrawMiniCal(-1, MiniCalWidth, MiniCal)
  539.     call DrawMiniCal(+1, MiniCalWidth, MiniCal)
  540.   end
  541.   /**/
  542.  
  543.   if DoCopyright == 1 then call RightText(PrintText(0, Margin.Top + PrintHeight + 2 * CalendarBorder + CalendarShadow, 4pt, 'N', Black$, 100, CNotice), Margin.Left + PrintWidth)
  544.   if App == 'PGS' then SELECTOBJECT NONE
  545.  
  546.   return
  547. /**/
  548.  
  549. /*** Subroutines ***/
  550. /***//*** AddBGUI (AB) ***/
  551. AddBGUI:
  552.   i = 0; AL_RexxBGUILib = i; AL_Lib.i = 'rexxbgui.library';    AL_MinVersion.i = 4;     AL_Offset.i = -30;  AL_Variable.i = 'RexxBGUILib'; AL_Status.i = "E"
  553.   i = 1; AL_BGUILib = i;     AL_Lib.i = 'bgui.library';        AL_MinVersion.i = 41.1;  AL_Offset.i = '' ;  AL_Variable.i = 'BGUILib';     AL_Status.i = "E"
  554.  
  555.   do i = 0 to 1
  556.     if exists('LIBS:'AL_lib.i) then do
  557.       AL_InstalledVersion = PgmVer('LIBS:'AL_lib.i)
  558.       AL_LibCount = AL_LibCount + 1
  559.       Library.Name.AL_LibCount = AL_Lib.i
  560.       Library.Version.AL_LibCount = AL_InstalledVersion
  561.       if (AL_InstalledVersion < AL_MinVersion.i) | (AL_InstalledVersion == '') then do
  562.         call AddMsg(AL_Status.i, AL_Lib.i' version 'AL_MinVersion.i' is required; your version is 'AL_InstalledVersion'.')
  563.         interpret Al_Variable.i' = 0'
  564.       end
  565.       else do
  566.         if i ~= AL_BGUILib then call addlib(AL_lib.i, 0, AL_Offset.i, trunc(AL_MinVersion.i))
  567.         interpret Al_Variable.i' = 1'
  568.       end
  569.     end
  570.     else do
  571.       interpret Al_Variable.i' = 0'
  572.       if (i = AL_RexxBGUILib) | (i = AL_BGUILib) then do
  573.         if GUIWarning == 0 then do
  574.           GUIWarning = 1
  575.           call AddMsg('E', 'Either the ClassAct files or the BGUI files (see the docs)')
  576.           call AddMsg('E', '  must be installed. Neither could be found...')
  577.         end
  578.       end
  579.       else if AL_Status.i == 'E' then call AddMsg('E', AL_lib.i' is required but could not be found.')
  580.     end
  581.   end
  582.   if RexxBGUILib == 1 then ClassAct = 0
  583.   if (ClassAct == 0) & (bguiopen = 0) then bguiopen = bguiopen()
  584.  
  585.   return
  586. /**/
  587.  
  588. /***//*** AddLibraries (AL) ***/
  589. AddLibraries:
  590.   AL_LibCount      = 0
  591.   DoingCleanup     = 0
  592.   PortList         = show('P')
  593.   InformationCount = 0
  594.   WarningCount     = 0
  595.   ErrorCount       = 0
  596.   HostScreen       = ''
  597.   Req              = 0
  598.   bguiopen         = 0
  599.   Storage          = 'RAM:FWC/'
  600.   ClassAct         = 0
  601.   ForceBGUI        = 0
  602.   ReqAPVersion     = 2.48
  603.   ReqCAVersion     = 42.80
  604.   ClassActMessage  = ''
  605.   AWNPipeMessage   = ''
  606.   GUIWarning       = 0
  607.  
  608.   call TranslationStrings
  609.   interpret ReadFile(ScriptDir'FWCTranslations.txt')
  610.  
  611.   i = 0; AL_DateLib = i;     AL_Lib.i = 'date.library';        AL_MinVersion.i = 33.31; AL_Offset.i = -492; AL_Variable.i = 'DateLib';     AL_Status.i = "W"
  612.   i = 1; AL_RexxMathLib = i; AL_Lib.i = 'rexxmathlib.library'; AL_MinVersion.i = 38.01;  AL_Offset.i = -30;  AL_Variable.i = 'RexxMathLib'; AL_Status.i = "W"
  613.  
  614.   if exists('L:awnpipe-handler') == 1 then do
  615.     AWNPipeVersion  = PgmVer('L:awnpipe-handler')
  616.     if exists('LIBS:gadgets/layout.gadget') == 1 then do
  617.       ClassActVersion = PgmVer('LIBS:gadgets/layout.gadget')
  618.       if ClassActVersion < ReqCAVersion then do
  619.         ClassActMessage = 'ClassAct version 'ReqCAVersion'+ is required; your version is 'ClassActVersion'. BGUI is being used'
  620.         ForceBGUI = 1
  621.       end
  622.       if AWNPipeVersion < ReqAPVersion then do
  623.         AWNPipeMessage = 'AWNPipe version 'ReqAPVersion'+ is required; your version is 'AWNPipeVersion'. BGUI is being used'
  624.         ForceBGUI = 1
  625.       end
  626.       if ForceBGUI == 0 then ClassAct = 1
  627.     end
  628.     else ForceBGUI = 1
  629.   end
  630.   else ForceBGUI = 1
  631.  
  632.   do i = 0 to 1
  633.     if exists('LIBS:'AL_lib.i) then do
  634.       AL_InstalledVersion = PgmVer('LIBS:'AL_lib.i)
  635.       AL_LibCount = AL_LibCount + 1
  636.       Library.Name.AL_LibCount = AL_Lib.i
  637.       Library.Version.AL_LibCount = AL_InstalledVersion
  638.       if (AL_InstalledVersion < AL_MinVersion.i) | (AL_InstalledVersion == '') then do
  639.         call AddMsg(AL_Status.i, AL_Lib.i' version 'AL_MinVersion.i' is required; your version is 'AL_InstalledVersion'.')
  640.         interpret Al_Variable.i' = 0'
  641.       end
  642.       else do
  643.         call addlib(AL_lib.i, 0, AL_Offset.i, trunc(AL_MinVersion.i))
  644.         interpret AL_Variable.i' = 1'
  645.       end
  646.     end
  647.     else do
  648.       interpret Al_Variable.i' = 0'
  649.       if AL_Status.i == 'E' then call AddMsg('E', AL_lib.i' is required but could not be found.')
  650.     end
  651.   end
  652.   if (DateLib == 1) | (RexxMathLib == 1) then PhaseLib = 1
  653.   else PhaseLib = 0
  654.  
  655.   if ForceBGUI == 1 then do
  656.     ClassAct = 0
  657.     call AddBGUI
  658.   end
  659.  
  660.   if ErrorCount > 0 then call Cleanup
  661.   return
  662. /**/
  663.  
  664. /***//*** AddMsg (AM) ***/
  665. AddMsg:
  666.   parse arg AM_MsgType, AM_Msg
  667.  
  668.   if AM_MsgType == 'E' then do
  669.     if symbol('ErrorCount') == 'LIT' then ErrorCount = 0
  670.     ErrorCount = ErrorCount + 1
  671.     Error.ErrorCount = AM_Msg
  672.   end
  673.   else if AM_MsgType == 'W' then do
  674.     if symbol('WarningCount') == 'LIT' then WarningCount = 0
  675.     WarningCount = WarningCount + 1
  676.     Warning.WarningCount = AM_Msg
  677.   end
  678.   else do
  679.     if symbol('InformationCount') == 'LIT' then InformationCount = 0
  680.     InformationCount = InformationCount + 1
  681.     Information.InformationCount = AM_Msg
  682.   end
  683.  
  684.   return 0
  685. /**/
  686.  
  687. /***//*** AssignHighlight (AH) ***/
  688. AssignHighlight:
  689.   parse arg AH_Month, AH_Day, AH_Event, AH_Color
  690.  
  691.   if upper(left(AH_Month, 9)) == 'HIGHLIGHT' then parse var AH_Month .'.'AH_Month'.'AH_Day'='AH_Event','AH_Color
  692.   if strip(AH_Event, 'B', '"'||"'") == '' then return 0
  693.   if AH_Month = 13 then AH_Month = Mn - 0
  694.   if AH_Color == '' then AH_Color = '<'Clear$'>'
  695.   AH_Event = strip(AH_Color, 'B', '" '||"'")||'00'x||substr(strip(AH_Event), 2, Length(strip(AH_Event)) - 2)
  696.   AH_DateString = DetermineDate(strip(AH_Month), strip(AH_Day), Year)
  697.   AH_Month = word(AH_DateString, 1)
  698.   AH_Day = word(AH_DateString, 2)
  699.  
  700.  
  701.   if Highlight.AH_Month.AH_Day == '' then Highlight.AH_Month.AH_Day = AH_Event
  702.   else Highlight.AH_Month.AH_Day = Highlight.AH_Month.AH_Day'//'AH_Event
  703.   HighlightCount = HighlightCount + 1
  704.  
  705.   do AH_i = 0 to ImageClass.Count - 1
  706.     if pos(upper(ImageClass.AH_i), upper(AH_Event)) > 0 then do
  707.       Image.AH_Month.AH_Day = AH_i
  708.       ImageCount = ImageCount + 1
  709.       leave
  710.     end
  711.   end
  712.  
  713.   return 0
  714. /**/
  715.  
  716. /***//*** AssignID (AID) ***/
  717. AssignID:
  718.   parse arg AID_Var, AID_ID
  719.   interpret AID_Var' = 'AID_ID
  720.   DSR_Gad.AID_ID = AID_Var
  721.   if left(AID_Var, 3) = 'Gad' then AID_Var = 'Extra'substr(AID_Var, 5, 1)
  722.   DSR_Help.AID_ID = AID_Var'Help'
  723.  
  724.   return
  725. /**/
  726.  
  727. /***//*** AssignImage (AI) ***/
  728. AssignImage:
  729.   parse arg AI_Month, AI_Day, AI_Image
  730.  
  731.   if DoImages ~= 1 then return 0
  732.   if upper(left(AI_Month, 5)) == 'IMAGE' then do
  733.     parse var AI_Month .'.'AI_Month'.'AI_Day'='AI_Image
  734.     AI_Image = substr(AI_Image, 2, Length(AI_Image) - 2)
  735.   end
  736.  
  737.   AI_Image = strip(AI_Image, 'B', '" '||"'")
  738.   parse var AI_Image AI_Image ',' AI_DX ',' AI_DY
  739.   if (pos('/', AI_Image) == 0) & (pos(':', AI_Image) == 0) then AI_Image = ScriptDir'Images/'strip(AI_Image, 'B', ' "'||"'")
  740.   AI_DX = strip(AI_DX);if AI_DX == '' then AI_DX = 0
  741.   AI_DY = strip(AI_DY);if AI_DY == '' then AI_DY = 0
  742.   AI_DateString = DetermineDate(strip(AI_Month), strip(AI_Day), Year)
  743.   AI_Month = word(AI_DateString, 1)
  744.   AI_Day = word(AI_DateString, 2)
  745.  
  746.   if exists(AI_Image) then do
  747.     ICCount = ImageClass.Count
  748.     Image.AI_Month.AI_Day = ICCount
  749.     ImageClass.ICCount = ''
  750.     ImageFile.ICCount = AI_Image
  751.     ImageDX.ICCount = AI_DX
  752.     ImageDY.ICCount = AI_DY
  753.     ImageClass.Count = ImageClass.Count + 1
  754.   end
  755.   return 0
  756. /**/
  757.  
  758. /***//*** BoxDate (BD) ***/
  759. BoxDate:
  760.   parse arg BD_DateBoxColor
  761.  
  762.   BD_DateBoxHeight = Height.Date
  763.  
  764.   call DrawBox(BoxLeft, BoxTop, CurveOffset + 2 * Width.WidthOfDate8 + DateOffset, BD_DateBoxHeight, 'HL', BD_DateBoxColor, 0, 0, 1, CRadius)
  765.   return
  766. /**/
  767.  
  768. /***//*** BuildString (BS) ***/
  769. BuildString:
  770.   parse arg BS_String, BS_Values
  771.  
  772.   do BS_i = 1 to words(BS_Values)
  773.     InsertPos = pos('%s', BS_String)
  774.     if InsertPos == 0 then leave
  775.     interpret "BS_String = left(BS_String, InsertPos - 1)''"word(BS_Values, BS_i)"''substr(BS_String, InsertPos + 2)"
  776.   end
  777.  
  778.   return BS_String
  779. /**/
  780.  
  781. /***//*** BuryObject (BO) ***/
  782. BuryObject:
  783.   parse arg BO_Object
  784.  
  785.   if App == 'FW' then OBJECTTOBACK BO_Object
  786.   else if App == 'PGS' then do
  787.     parse arg BO_Object
  788.     SENDTOBACK OBJECTID BO_Object WINDOW winName
  789.   end
  790.  
  791.   return BO_Object
  792. /**/
  793.  
  794. /***//*** BusyReq (BR) ***/
  795. /***//*** OpenBusy ***/
  796. OpenBusy:
  797.   parse arg BR_BusyTitle, BR_EventCount
  798.  
  799.   BR_Progress = 0
  800.   if ClassAct == 1 then do
  801.     call open('ProgReq', "awnpipe:ProgressReq/xc")
  802.     call ToPIPE('ProgReq', 'm v cs si so a ps="'AppScreen'"')
  803.     call ToPIPE('ProgReq', 'label gt="'BR_BusyTitle', 'PleaseWait$'..."')
  804.     BR_ProgressGad = ToPIPE('ProgReq', 'fuelgauge defn=0 maxn='BR_EventCount' t=0 per')
  805.     call ToPIPE('ProgReq', 'layout b=0 si so cj')
  806.       call ToPIPE('ProgReq', 'space')
  807.       BR_CancelGad = ToPIPE('ProgReq', 'button pb gt="'Cancel$'"')
  808.       call ToPIPE('ProgReq', 'space')
  809.     call ToPIPE('ProgReq', 'le')
  810.     if ToPIPE('ProgReq', 'open') == 'window' then BR_ProgressWindow = 1
  811.     else BR_ProgressWindow = 0
  812.   end
  813.   else do
  814.     BR_ProgressGroup=bguivgroup(,
  815.           bguiinfo('BR_dummy',,'1B'x||'c'BR_BusyTitle', 'PleaseWait$'...')bguilayout(LGO_FixMinHeight,1)||,
  816.           bguiprogress('BR_prog2_',,0,BR_EventCount)||,
  817.           bguihgroup(,
  818.                   bguivarspace(50)bguilayout(LGO_FixMinHeight,1)||,
  819.                   bguibutton('BR_cancel_',Cancel$)bguilayout(LGO_FixMinHeight,1)||,
  820.                   bguivarspace(50)bguilayout(LGO_FixMinHeight,1),
  821.           ,,,,'W'),
  822.     ,-2,-2)
  823.     BR_ProgressWindow = bguiwindow('',BR_ProgressGroup,,2,,AppScreen)
  824.     if bguiwinopen(BR_ProgressWindow) = 0 then call Cleanup
  825.   end
  826.  
  827.   return BR_ProgressWindow
  828. /**/
  829.  
  830. /***//*** UpdateBusy ***/
  831. UpdateBusy:
  832.   parse arg BR_ReqWin, BR_ProgressMade
  833.  
  834.   if BR_ReqWin == 0 then return 0
  835.   BR_Progress = BR_Progress + BR_ProgressMade
  836. /* say '>'BR_Progress SIGL */
  837.   if ClassAct == 1 then do
  838.     if show('F', 'ProgReq') == 1 then do
  839.       call writeln('ProgReq', 'id 'BR_CancelGad' read')
  840.       BR_CancelStatus = readln('ProgReq')
  841.       if BR_CancelStatus == 1 then do
  842.         call CloseBusy('ProgReq')
  843.         return -1
  844.       end
  845.     end
  846.     else return 0
  847.     if show('F', 'ProgReq') == 1 then do
  848.       call ToPIPE('ProgReq', 'id 0 s=2')
  849.       call writeln('ProgReq', 'id 'BR_ProgressGad' defn='BR_Progress' ref')
  850.       call readln('ProgReq')
  851.     end
  852.     else return 0
  853.   end
  854.   else do
  855.     call bguiset(obj.BR_prog2_,BR_ReqWin,PROGRESS_Done,BR_Progress)
  856.     if bguiwinevent(BR_ReqWin,'ID') == id.BR_cancel_ then return -1
  857.   end
  858.  
  859.   return BR_Progress
  860. /**/
  861.  
  862. /***//*** CloseBusy ***/
  863. CloseBusy:
  864.   parse arg BR_ReqWin
  865.  
  866.   if BR_ReqWin == 0 then return 0
  867.  
  868.   if ClassAct == 1 then call close('ProgReq')
  869.   else call bguiwinclose(BR_ReqWin)
  870.   Req = 0
  871.  
  872.   return 0
  873. /**/
  874. /**/
  875.  
  876. /***//*** CalculateDate (CD) ***/
  877. CalculateDate:
  878. /* Month    is the month in which the highlight occurs                        */
  879. /* HighDate is the highest (numerical) date on which the highlight will occur */
  880. /* HighDay  is the weekday on which the month starts when HighDate will occur */
  881. /* Event    is the highlight text                                             */
  882.   parse arg CD_Month, CD_HighDay, CD_HighDate, CD_Event, CD_Color
  883.  
  884.   CD_Event = QuoteIt(CD_Event)
  885.   if CD_Month = 13 then CD_Month = Mn - 0
  886.  
  887.   if datatype(CD_HighDate) == 'CHAR' then do
  888.     CD_HighDate = upper(left(CD_HighDate, 1))
  889.     interpret 'CD_EventOffset = Day.'CD_HighDay' - StartDate'
  890.  
  891.     CD_Day  = 1 + CD_EventOffset
  892.     if CD_Day < 1 then CD_Day = CD_Day + 7
  893.  
  894.     do until CD_Day > Monthlength.Month
  895.       CD_WN = trunc((right(DateInfo('J', Year''right(CD_Month, 2, '0')''right(CD_Day, 2, '0'), 'S'), 3) - YearOffset - 1)/7 + 1)
  896.       if CD_HighDate == 'A' then call AssignHighlight(CD_Month, CD_Day, CD_Event, CD_Color)
  897.       else if (CD_HighDate == 'E') & (CD_WN//2 == 0) then call AssignHighlight(CD_Month, CD_Day, CD_Event, CD_Color)
  898.       else if (CD_HighDate == 'O') & (CD_WN//2 == 1) then call AssignHighlight(CD_Month, CD_Day, CD_Event, CD_Color)
  899.       CD_Day = CD_Day + 7
  900.     end
  901.   end
  902.   else do
  903.     interpret 'CD_HighDay = Day.'CD_HighDay
  904.     interpret 'CD_First = Day.'DateInfo('W', Year''right(CD_Month, 2, '0')'01', 'S')
  905.  
  906.     CD_Day = CD_HighDate + (CD_HighDay - CD_First)
  907.     if CD_First < CD_HighDay then CD_Day = CD_Day - 7
  908.     if CD_Event ~= '' then call AssignHighlight(CD_Month, CD_Day, CD_Event, CD_Color)
  909.   end
  910. return CD_Day
  911. /**/
  912.  
  913. /***//*** CalculateEDate (CED) ***/
  914. CalculateEDate:
  915. /* DaysPastEaster is the number of days past Easter when the event occurs */
  916. /* Event          is the highlight text                                   */
  917.   parse arg CED_DaysPastEaster, CED_EasterEvent, CED_Color
  918.  
  919.   CED_EasterEvent = '"'CED_EasterEvent'"'
  920.   CED_EasterEventDate = DateInfo('S', EasterSerial + CED_DaysPastEaster, 'I')
  921.   CED_EasterEventMonth = strip(substr(CED_EasterEventDate, 5, 2), 'L', '0')
  922.   CED_EasterEventDay = strip(right(CED_EasterEventDate, 2), 'L', '0')
  923.   call AssignHighlight(CED_EasterEventMonth, CED_EasterEventDay, CED_EasterEvent, CED_Color)
  924. return 0
  925. /**/
  926.  
  927. /***//*** CalculateImage (CI) ***/
  928. CalculateImage:
  929. /* Month    is the month in which the highlight occurs                        */
  930. /* HighDate is the highest (numerical) date on which the highlight will occur */
  931. /* HighDay  is the weekday on which the month starts when HighDate will occur */
  932. /* Event    is the highlight text                                             */
  933.   parse arg CI_Month, CI_HighDay, CI_HighDate, CI_Image
  934.  
  935.   if DoImages ~= 1 then return 0
  936.  
  937.   if CI_Month = 13 then CI_Month = Mn - 0
  938.  
  939.   if datatype(CI_HighDate) == 'CHAR' then do
  940.     CI_HighDate = upper(left(CI_HighDate, 1))
  941.     interpret 'CI_EventOffset = Day.'CI_HighDay' - StartDate'
  942.  
  943.     CI_Day  = 1 + CI_EventOffset
  944.     if CI_Day < 1 then CI_Day = CI_Day + 7
  945.  
  946.     do until CI_Day > Monthlength.Month
  947.       CI_WN = trunc((right(DateInfo('J', Year''right(CI_Month, 2, '0')''right(CI_Day, 2, '0'), 'S'), 3) - YearOffset - 1)/7 + 1)
  948.       if CI_HighDate == 'A' then call AssignImage(CI_Month, CI_Day, CI_Image)
  949.       else if (CI_HighDate == 'E') & (CI_WN//2 == 0) then call AssignImage(CI_Month, CI_Day, CI_Image)
  950.       else if (CI_HighDate == 'O') & (CI_WN//2 == 1) then call AssignImage(CI_Month, CI_Day, CI_Image)
  951.       CI_Day = CI_Day + 7
  952.     end
  953.   end
  954.   else do
  955.     interpret 'CI_HighDay = Day.'CI_HighDay
  956.     interpret 'CI_First = Day.'DateInfo('W', Year''right(CI_Month, 2, '0')'01', 'S')
  957.  
  958.     CI_Day = CI_HighDate + (CI_HighDay - CI_First)
  959.     if CI_First < CI_HighDay then CI_Day = CI_Day - 7
  960.     if CI_Event ~= '' then call AssignImage(CI_Month, CI_Day, CI_Image)
  961.     else return CI_Day
  962.   end
  963. return 0
  964. /**/
  965.  
  966. /***//*** CAGetFile (GF) ***/
  967. CAGetFile:
  968.   parse arg GF_FileHandle, GF_GadID, GF_Title, GF_InitDir
  969.  
  970.   call writeln(GF_FileHandle,'id 'GF_GadID' gt="'GF_Title':" fn="'GF_InitDir'" s=1')
  971.   GF_GetFileResult = readln(GF_FileHandle)
  972.   parse var GF_GetFileResult GF_OK GF_Choice GF_File
  973.   if GF_Choice ~= 0 then GF_File = strip(GF_File, 'B', '" ')
  974.   else GF_File = ''
  975.  
  976.   return GF_File
  977. /**/
  978.  
  979. /***//*** CASimpleReq (CAS) ***/
  980. CASimpleReq:
  981.   parse arg CAS_Title, CAS_Msg, CAS_Time
  982.  
  983.   if CAS_Time == '' then do
  984.     CAS_Msg = translate(CAS_Msg, "'", '"')
  985.     do while pos('0a'x, CAS_Msg) > 0
  986.       CAS_Msg = left(CAS_Msg, pos('0a'x, CAS_Msg) - 1)'*n'substr(CAS_Msg, pos('0a'x, CAS_Msg) + 1)
  987.     end
  988.  
  989.     call open('Req', "awnpipe:SimpleReq/xc")
  990.     call ToPIPE('Req', '"'CAS_Title'" v db dg si so a ps="'AppScreen'"')
  991.     call ToPIPE('Req', 'label gt="'CAS_Msg'"')
  992.     call ToPIPE('Req', 'layout b=0 si so cj')
  993.       call ToPIPE('Req', 'space')
  994.       call ToPIPE('Req', 'button c gt="'OK$'"')
  995.       call ToPIPE('Req', 'space')
  996.     call ToPIPE('Req', 'le')
  997.     call ToPIPE('Req', 'open')
  998.  
  999.     do while ~eof('Req')
  1000.       call readln('Req')
  1001.     end
  1002.     call close('Req')
  1003.   end
  1004.   else do
  1005.     call open('Req', "awnpipe:SimpleReq/xc")
  1006.     call ToPIPE('Req', 'm sk si so a ps="'AppScreen'"')
  1007.     call ToPIPE('Req', 'label gt="'CAS_Msg'"')
  1008.     call ToPIPE('Req', 'open')
  1009.  
  1010.     CAS_TickCount = 0
  1011.     do until CAS_TickCount >= CAS_Time
  1012.       call ToPIPE('Req', 'tick 100')
  1013.       Req_EventInfo = readln('Req')
  1014.       parse var Req_EventInfo Req_Event' 'Req_GadID' 'Req_GadInfo1
  1015.       select
  1016.         when Req_Event == 'key' then CAS_TickCount = CAS_Time
  1017.         when Req_Event = 'tick' then CAS_TickCount = CAS_TickCount + 1
  1018.         otherwise nop
  1019.       end
  1020.     end
  1021.     call close('Req')
  1022.   end
  1023.  
  1024.   return
  1025. /**/
  1026.  
  1027. /***//*** CenterText (CT) ***/
  1028. CenterText:
  1029.   parse arg CT_id, CT_CenterPoint, CT_MaxWidth, CT_WidthPercent
  1030.  
  1031.   if App == 'FW' then do
  1032.     GETOBJECTCOORDS CT_id; Parse Var result . . CT_Text.Bottom CT_Text.Width CT_Text.Height
  1033.     if CT_MaxWidth ~= 0 then CT_Text.Width = min(CT_Text.Width, CT_MaxWidth)
  1034.     else CT_Text.Width = CT_Text.Width * CT_WidthPercent
  1035.     CT_Text.Left = CT_CenterPoint - CT_Text.Width/2
  1036.     SETOBJECTCOORDS CT_id 1 CT_Text.Left CT_Text.Bottom CT_Text.Width CT_Text.Height
  1037.   end
  1038.   else if App == 'PGS' then do
  1039.     GETTEXTOBJ POSITION CT_Text OBJECTID CT_id WINDOW winName
  1040.     CT_Text.Width = CT_Text.Right - CT_Text.Left
  1041.     if CT_MaxWidth ~= 0 then CT_Text.Width = min(CT_Text.Width, CT_MaxWidth)
  1042.     else CT_Text.Width = CT_Text.Width * CT_WidthPercent
  1043.     CT_Text.Left = CT_CenterPoint - CT_Text.Width/2
  1044.     EDITTEXTOBJ POSITION CT_Text.Left CT_Text.Top (CT_Text.Left + CT_Text.Width) CT_Text.Bottom OBJECTID CT_id WINDOW winName
  1045.   end
  1046.  
  1047.   return CT_id
  1048. /**/
  1049.  
  1050. /***//*** CheckDir (PROCEDURE) ***/
  1051. CheckDir: PROCEDURE
  1052.   parse arg Dir
  1053.  
  1054.   address command 'assign >NIL: FWC: 'Dir
  1055.   if RC == 20 then return ''
  1056.   else do
  1057.     address command 'assign >NIL: FWC:'
  1058.     return Dir
  1059.   end
  1060.  
  1061.   return
  1062. /**/
  1063.  
  1064. /***//*** Cleanup () ***/
  1065. Cleanup:
  1066.   signal off syntax
  1067.   DoingCleanup = 1
  1068.   call close('DataFile')
  1069.   call close('CA')
  1070.  
  1071.   call CloseBusy(Req)
  1072.  
  1073.   if App == 'FW' then do
  1074.     SELECTOBJECT
  1075.     VIEW FinalView
  1076.     if VariablesSet == 1 then do
  1077.       interpret UserPrefs
  1078.       if upper(DecimalFormat) = 'COMMA' then DOCITEMPREFS DECIMAL Comma
  1079.     end
  1080.   end
  1081.   else if App == 'PGS' then do
  1082.     if VariablesSet == 1 then interpret UserPrefs
  1083.     LOCKINTERFACE FALSE
  1084.     LOADSETTINGS default
  1085.     REFRESH ON
  1086.     REFRESHWINDOW WINDOW winName
  1087.     DISPLAY SCALE FinalView WINDOW winName
  1088.     DISPLAY PAGE 1
  1089.     REVEALWINDOW ALL
  1090.   end
  1091.  
  1092.   if (ErrorCount == 0) & (CalType < 3) & (LaunchM ~= '') then interpret LaunchM
  1093.   if (ErrorCount == 0) & (CalType == 3) & (LaunchY ~= '') then interpret LaunchY
  1094.  
  1095.   LogOpen = open('FWCLog', Storage'FWCLog.txt', 'W')
  1096.   if LogOpen == 0 then do
  1097.     address command 'makedir >NIL: 'left(Storage, length(Storage) - 1)
  1098.     LogOpen = open('FWCLog', Storage'FWCLog.txt', 'W')
  1099.   end
  1100.   if LogOpen == 1 then OutType = 'File'
  1101.  
  1102.   if ((WarningCount > 0) | (ErrorCount > 0) | (InformationCount > 0)) & (LogOpen == 0) then do
  1103.     LogOpen = 1
  1104.     call open('FWCLog', 'CON:10/10/500/300/FWCalendar.rexx Message/WAIT/CLOSE')
  1105.     OutType = 'CON'
  1106.   end
  1107.  
  1108.   if LogOpen == 1 then do
  1109.     call writeln('FWCLog', '      Macro: 'strip(substr(sourceline(4), pos(':', sourceline(4)) + 1)))
  1110.     call writeln('FWCLog', 'Application: 'NameAndVersion)
  1111.     call writeln('FWCLog', 'Current Dir: 'CurrentDir)
  1112.     call writeln('FWCLog', ' Script Dir: 'ScriptDir)
  1113.     call writeln('FWCLog', '       Host: 'CallHost)
  1114.     call writeln('FWCLog', '   Calendar: 'Calendar||'0a'x)
  1115.  
  1116.     interpret 'address command "version >PIPE:FWC"'
  1117.     Ln = ReadFile('PIPE:FWC')
  1118.     KS  = strip(word(Ln, 2), 'B', ' ,')
  1119.     WB  = strip(word(Ln, 4))
  1120.  
  1121.     interpret 'address command "cpu >PIPE:FWC"'
  1122.     CPULn = ReadFile('PIPE:FWC')
  1123.     CPU = strip(word(CPULn, 2))
  1124.  
  1125.     interpret 'address command "avail >PIPE:FWC"'
  1126.     AvailLn = ReadFile('PIPE:FWC')
  1127.     call OpenV('AvailLn')
  1128.       call readvln('AvailLn')
  1129.       ChipRAM = strip(word(readvln('AvailLn'), 2))
  1130.       FastRAM = strip(word(readvln('AvailLn'), 2))
  1131.     call CloseV('AvailLn')
  1132.     MaxLen  = max(length(ChipRAM), length(FastRAM))
  1133.  
  1134.     call writeln('FWCLog', '  Kickstart: 'KS)
  1135.     call writeln('FWCLog', '  Workbench: 'WB)
  1136.     call writeln('FWCLog', '        CPU: 'CPU)
  1137.     call writeln('FWCLog', '   Chip RAM: 'right(ChipRAM, MaxLen)' available')
  1138.     call writeln('FWCLog', '   Fast RAM: 'right(FastRAM, MaxLen)' available')
  1139.  
  1140.     if AL_LibCount > 0 then do
  1141.       call writeln('FWCLog', '  Libraries: 'left(Library.Name.1, 21)'v'Library.Version.1)
  1142.       do i = 2 to AL_LibCount
  1143.         call writeln('FWCLog', '             'left(Library.Name.i, 21)'v'Library.Version.i)
  1144.       end
  1145.       call writeln('FWCLog', '')
  1146.     end
  1147.     else call writeln('FWCLog', '0a'x||'No libraries added.')
  1148.  
  1149.     if AWNPipeMessage ~= '' then call writeln('FWCLog', AWNPipeMessage)
  1150.     if ClassActMessage ~= '' then call writeln('FWCLog', ClassActMessage)
  1151.     call writeln('FWCLog', '')
  1152.   end
  1153.  
  1154.   if (ErrorCount > 0) | (WarningCount > 0) | (InformationCount > 0) then do
  1155.     do i = 1 to ErrorCount
  1156.       call writeln('FWCLog', 'Error: 'Error.i)
  1157.     end
  1158.  
  1159.     do i = 1 to WarningCount
  1160.       call writeln('FWCLog', 'Warning: 'Warning.i)
  1161.     end
  1162.  
  1163.     do i = 1 to InformationCount
  1164.       call writeln('FWCLog', 'Information: 'Information.i)
  1165.     end
  1166.  
  1167.     if (ErrorCount > 0) | (WarningCount > 0) then do
  1168.       if PrefsFile ~= 'Default' then do
  1169.         if (exists(PrefsFile)) & (length(ReadFile(PrefsFile)) > 2) then do
  1170.           call writeln('FWCLog', '0a'x||' -- 'PrefsFile' -- ')
  1171.           if open('DataFile', PrefsFile) then do
  1172.             do until eof('DataFile')
  1173.               if ~eof('DataFile') then do
  1174.                 Ln = ReadLn('DataFile')
  1175.                 call writeln('FWCLog', Ln)
  1176.               end
  1177.             end
  1178.             call close('DataFile')
  1179.           end
  1180.         end
  1181.       end
  1182.  
  1183.       if ErrorCount > 0 then ErrorType = Critical$
  1184.       else ErrorType = Noncritical$
  1185.       FileMsg = ErrorType' ... 'See$' 'Storage'FWCLog.txt 'ForDetails$'.'||'0a'x||ForwardLog$': Ron Goertz <goertz@earthlink.net>'||'0a'x||Unable$
  1186.       Conbgui = ErrorType' ... 'SeeShell$'.'||'0a'x||ForwardContent$||'0a'x||'Ron Goertz <goertz@earthlink.net>'||'0a'x||Unable$
  1187.       ConCon  = ErrorType' ... 'SeeOutput$'.'||'0a'x||ForwardContent$||'0a'x||'Ron Goertz <goertz@earthlink.net>'||'0a'x||Unable$
  1188.       if (OutType == 'File') & (ClassAct == 1) then call CASimpleReq('FWCalendar 'Notice$, FileMsg)
  1189.       if (OutType == 'File') & (bguiopen == 1) then call bguireq('1B'x||'c'FileMsg,'*'OK$,'FWCalendar 'Notice$,,AppScreen)
  1190.       if (OutType == 'File') & (bguiopen == 0) & (ClassAct == 0) then do
  1191.         call open('CON', 'CON:10/10/500/300/FWCalendar notice/WAIT/CLOSE')
  1192.           call writeln('CON', FileMsg)
  1193.         call close('CON')
  1194.       end
  1195.  
  1196.       if (OutType == 'CON') & (ClassAct == 1) then call CASimpleReq('FWCalendar 'Notice$, Conbgui)
  1197.       if (OutType == 'CON') & (bguiopen == 1) then call bguireq('1B'x||'c'Conbgui,'*'OK$,'FWCalendar 'Notice$,,AppScreen)
  1198.       if (OutType == 'CON') & (bguiopen == 0) & (ClassAct == 0) then call Writeln('FWCLog', '0a'x||ConCon)
  1199.     end
  1200.   end
  1201.   if (ErrorCount == 0) & (WarningCount == 0) then do
  1202.     if LogOpen == 1 then call writeln('FWCLog', 'No errors.')
  1203.   end
  1204.  
  1205.   address command 'delete >NIL: 'Storage'FWC'App'Temp.txt quiet'
  1206.   address command 'delete >NIL: 'Storage'FWCTemp quiet'
  1207.   call close('FWCLog')
  1208.   if bguiopen = 1 then call bguiclose()
  1209.  
  1210.   exit
  1211. /**/
  1212.  
  1213. /***//*** ConvertChangesFile (CCF) ***/
  1214. ConvertChangesFile:
  1215.   /* Determine current prefs file */
  1216.   if length(readfile(ScriptDir'FWC.dat')) < 2 then return
  1217.  
  1218.   CCF_DataFile = ReadFile(ScriptDir'FWC.dat')
  1219.   if CCF_DataFile ~= '' then do
  1220.     call openv('CCF_DataFile')
  1221.       CCF_DataVersion = readvln('CCF_DataFile')
  1222.       PrefsFile = readvln('CCF_DataFile')
  1223.       PrefsFile = strip(substr(PrefsFile, pos('=', PrefsFile) + 1),," '")
  1224.       CCF_Data = readvch('CCF_DataFile', 65535)
  1225.     call closev('CCF_DataFile')
  1226.     call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  1227.  
  1228.     if PrefsFile ~= 'Default' then do
  1229.       /* Move translation strings to separate file */
  1230.       if open('DataFile', PrefsFile) then do
  1231.         call openv('CCF_TranslationFile')
  1232.         call openv('CCF_DataFile')
  1233.         do until eof('DataFile')
  1234.           CCF_Ln = ReadLn('DataFile')
  1235.           CCF_Var = upper(word(CCF_Ln, 1))
  1236.           if right(CCF_Var, 1) == '$' then call writevln('CCF_TranslationFile', compress(CCF_Ln, ':'))
  1237.           else call writevln('CCF_DataFile', CCF_Ln)
  1238.         end
  1239.         call closev('CCF_DataFile')
  1240.         call closev('CCF_TranslationFile')
  1241.         call close('DataFile')
  1242.         if CCF_TranslationFile ~= '' then do
  1243.           if open('DataFile', ScriptDir'FWCTranslations.txt', 'W') then do
  1244.             call writeln('DataFile', '/* FWC Translation file v4.x */')
  1245.             call writeln('DataFile', CCF_TranslationFile)
  1246.             call close('DataFile')
  1247.             interpret ReadFile(ScriptDir'FWCTranslations.txt')
  1248.           end
  1249.           else call AddMsg('W', 'Unable to create translation file.')
  1250.         end
  1251.         if open('DataFile', PrefsFile, 'W') then do
  1252.           call writeln('DataFile', CCF_DataFile)
  1253.           call close('DataFile')
  1254.         end
  1255.         else do
  1256.           call AddMsg('E', 'Unable to re-create preference file.')
  1257.           call Cleanup
  1258.         end
  1259.       end
  1260.     end
  1261.   end
  1262.   address command 'delete >NIL: 'ScriptDir'FWC.dat'
  1263.  
  1264.   return
  1265. /**/
  1266.  
  1267. /***//*** ConvertJ (CJ) ***/
  1268. /* Routine to convert from 'J' & 'F' to normal dates obtained from the Sky & Telescope */
  1269. /* web site. The basic program from which the following was derived originally    */
  1270. /* appeared in Astronomical Computing, Sky & Telescope, May, 1984                 */
  1271. ConvertJ:
  1272.   parse arg CJ_F, CJ_J
  1273.  
  1274.   CJ_F = CJ_F + 0.5
  1275.   if CJ_F >= 1 then do
  1276.     CJ_F = CJ_F - 1
  1277.     CJ_J = CJ_J + 1
  1278.   end
  1279.   CJ_A1 = trunc((CJ_J / 36524.25) - 51.12264)
  1280.   CJ_A = CJ_J + 1 + CJ_A1 - trunc(CJ_A1 / 4)
  1281.   CJ_B = CJ_A + 1524
  1282.   CJ_C = trunc((CJ_B / 365.25) - 0.3343)
  1283.   CJ_D = trunc(365.25 * CJ_C)
  1284.   CJ_E = trunc((CJ_B - CJ_D) / 30.61)
  1285.   CJ_D = CJ_B - CJ_D - trunc(30.61 * CJ_E) + CJ_F
  1286.   CJ_M = CJ_E - 1
  1287.   CJ_Y = CJ_C - 4716
  1288.   IF CJ_E > 13.5 then CJ_M = CJ_M - 12
  1289.   IF CJ_M < 2.5 then CJ_Y = CJ_Y + 1
  1290.   CJ_Day = trunc(CJ_D)
  1291.  
  1292.   return right(CJ_Y, 4, '0')' 'right(CJ_M, 2, '0')' 'right(CJ_Day, 2, '0')' 'CJ_D - CJ_Day
  1293. /**/
  1294.  
  1295. /***//*** ControlMX (CM) ***/
  1296. ControlMX:
  1297.   parse arg CM_SourceGrp, CM_SourcePosn
  1298.  
  1299.   DSR_Sel.CM_SourceGrp = CM_SourcePosn
  1300.   if DSR_Sel.CM_SourceGrp == DSR_PSel.CM_SourceGrp then do
  1301.     if ClassAct == 1 then call ToPIPE('CA', 'id 'Gad.CM_SourceGrp.CM_SourcePosn' s=1 page='ClickTab' refresh')
  1302.     return
  1303.   end
  1304.  
  1305.   CM_PSelect = DSR_PSel.CM_SourceGrp
  1306.   CM_Select  = DSR_Sel.CM_SourceGrp
  1307.   GadSel.CM_SourceGrp.CM_PSelect = 0
  1308.   GadSel.CM_SourceGrp.CM_Select  = 1
  1309.   if ClassAct == 1 then call ToPIPE('CA', 'id 'Gad.CM_SourceGrp.CM_PSelect' s=0 page='ClickTab' refresh')
  1310.  
  1311.   do CM_DestGrp = 0 to GroupCount
  1312.     /* nop for source group */
  1313.     if CM_DestGrp == CM_SourceGrp then iterate
  1314.  
  1315.     if CM_PSelect ~= 0 then do
  1316.       /* Update enables in disable string */
  1317.       DSR_Dis.CM_DestGrp = overlay(substr(DSR_Dis.CM_DestGrp, CM_PSelect + 1, 1) - 1, DSR_Dis.CM_DestGrp, CM_PSelect + 1)
  1318.       do CM_i = 1 to MXPairCount
  1319.         if (substr(word(MXPair.CM_i, 1), CM_SourceGrp + 1, 1) == '1') & (substr(word(MXPair.CM_i, 1), CM_DestGrp + 1, 1) == '1') then do
  1320.           call CM_SetDisables(CM_PSelect, word(MXPair.CM_i, 2), word(MXPair.CM_i, 3), 'Enable')
  1321.           call CM_SetDisables(CM_PSelect, word(MXPair.CM_i, 3), word(MXPair.CM_i, 2), 'Enable')
  1322.         end
  1323.       end
  1324.     end
  1325.  
  1326.     if CM_Select ~= 0 then do
  1327.       /* Update disables in disable string */
  1328.       DSR_Dis.CM_DestGrp = overlay(substr(DSR_Dis.CM_DestGrp, CM_Select + 1, 1) + 1, DSR_Dis.CM_DestGrp, CM_Select + 1)
  1329.       do CM_i = 1 to MXPairCount
  1330.         if (substr(word(MXPair.CM_i, 1), CM_SourceGrp + 1, 1) == '1') & (substr(word(MXPair.CM_i, 1), CM_DestGrp + 1, 1) == '1') then do
  1331.           call CM_SetDisables(CM_Select, word(MXPair.CM_i, 2), word(MXPair.CM_i, 3), 'Disable')
  1332.           call CM_SetDisables(CM_Select, word(MXPair.CM_i, 3), word(MXPair.CM_i, 2), 'Disable')
  1333.         end
  1334.       end
  1335.     end
  1336.   end
  1337.  
  1338.   /* Update previous select posn */
  1339.   DSR_PSel.CM_SourceGrp = DSR_Sel.CM_SourceGrp
  1340.  
  1341.   do CM_Grp = 0 to GroupCount
  1342.     do forever
  1343.       /* Determine differences between previous- and current-disable strings */
  1344.       /* -1 means strings are the same */
  1345.       comp = compare(DSR_Dis.CM_Grp, DSR_PDis.CM_Grp) - 1
  1346.       if comp > -1 then do
  1347.         /* Make change to GUI */
  1348.         GadDis.CM_Grp.comp = substr(DSR_Dis.CM_Grp, comp + 1, 1)
  1349.         if ClassAct == 1 then do
  1350.           if datatype(Gad.CM_Grp.comp) == 'NUM' then call ToPIPE('CA', 'id 'Gad.CM_Grp.comp' dis='substr(DSR_Dis.CM_Grp, comp + 1, 1)' page='ClickTab' refresh')
  1351.         end
  1352.         else do
  1353.           CM_Action = sign(substr(DSR_Dis.CM_Grp, comp + 1, 1))
  1354.           interpret 'call bguiset('grp.CM_Grp',winID,'Action.CM_Action',comp)'
  1355.         end
  1356.         /* Update previous-disable string */
  1357.         DSR_PDis.CM_Grp = overlay(substr(DSR_Dis.CM_Grp, comp + 1, 1), DSR_PDis.CM_Grp, comp + 1)
  1358.       end
  1359.       else leave
  1360.     end
  1361.   end
  1362.  
  1363.   return
  1364.  
  1365. /***//*** CM_SetDisables (CMSD) ***/
  1366. CM_SetDisables:
  1367.   parse arg CMSD_KeyPosn, CMSD_MX1, CMSD_MX2, CMSD_Action
  1368.  
  1369.   if upper(CMSD_Action) == 'ENABLE' then CMSD_Sign = -1
  1370.   else CMSD_Sign = 1
  1371.  
  1372.   if substr(CMSD_MX1, CMSD_KeyPosn, 1) == 1 then do
  1373.     CMSD_Posn = 0
  1374.     do CMSD_j = 1 to length(CMSD_MX2) - length(compress(CMSD_MX2, '1'))
  1375.       CMSD_Posn = pos('1', CMSD_MX2, CMSD_Posn + 1)
  1376.       /* Enable/Disable MX pairs */
  1377.       DSR_Dis.CM_DestGrp = overlay(substr(DSR_Dis.CM_DestGrp, CMSD_Posn + 1, 1) + CMSD_Sign, DSR_Dis.CM_DestGrp, CMSD_Posn + 1)
  1378.     end
  1379.   end
  1380.  
  1381.   return
  1382. /**/
  1383.  
  1384. /**/
  1385.  
  1386. /***//*** DateInfo (PROCEDURE) ***/
  1387. DateInfo: PROCEDURE
  1388.   /* DateInfo('I', '19780101', 'S') = 2443510  */
  1389.   /* Date('I', '19780101', 'S') = 0            */
  1390.   /* Option 'C' returns days since Jan 1, xx00 */
  1391.   parse arg Option, Date, Format
  1392.  
  1393.   if Option == '' then Option = 'N'
  1394.   if Date == '' then do
  1395.     Date = Date('S')
  1396.     Format = 'S'
  1397.   end
  1398.  
  1399.   Option = upper(left(Option, 1))
  1400.   Format = upper(left(Format, 1))
  1401.   if (Format == 'I') | (Format = '') then do
  1402.     Format = 'I'
  1403.  
  1404.     /* Routine to convert from a serial date to year/month/day obtained from the        */
  1405.     /* Sky & Telescope web site. The basic program from which the following was         */
  1406.     /* derived originally appeared in Astronomical Computing, Sky & Telescope,May, 1984 */
  1407.     A1 = trunc((Date / 36524.25) - 51.12264)
  1408.     A = Date + 1 + A1 - trunc(A1 / 4)
  1409.     B = A + 1524
  1410.     C = trunc((B / 365.25) - 0.3343)
  1411.     D = trunc(365.25 * C)
  1412.     E = trunc((B - D) / 30.61)
  1413.     D = B - D - trunc(30.61 * E)
  1414.     Month = E - 1
  1415.     Year = C - 4716
  1416.     IF E > 13.5 then Month = Month - 12
  1417.     IF Month < 2.5 then Year = Year + 1
  1418.     Day = trunc(D)
  1419.     J = Date
  1420.   end
  1421.   else do
  1422.     Year  = left(Date, 4) - 0
  1423.     Month = substr(Date, 5, 2) - 0
  1424.     Day   = right(Date, 2) - 0
  1425.     /* The following two lines are modified from PerpetualCalendar.bas that */
  1426.     /* appeared in Astronomical Computing, Sky & Telescope, July, 1985      */
  1427.     Temp = 0; if Month <= 2 then Temp = -1
  1428.     J = 367*Year-trunc(7*(Year+trunc((Month + 9)/12))/4)+trunc(275*Month/9)+1721031-trunc(3*(trunc((Year+Temp)/100)+1)/4) + Day - 2
  1429.   end
  1430.  
  1431.   select
  1432.     when Option == 'B' then do
  1433.       return J - 1721060
  1434.     end
  1435.     when Option == 'C' then do
  1436.       return J + 2 - DateInfo('I', left(right(Year, 4, '0'), 2)'000101', 'S')
  1437.     end
  1438.     when (Option == 'D') | (Option == 'J') then do
  1439.       DayCount = 0
  1440.       MonthLength.1    = 31
  1441.       MonthLength.2    = 28
  1442.       MonthLength.3    = 31
  1443.       MonthLength.4    = 30
  1444.       MonthLength.5    = 31
  1445.       MonthLength.6    = 30
  1446.       MonthLength.7    = 31
  1447.       MonthLength.8    = 31
  1448.       MonthLength.9    = 30
  1449.       MonthLength.10   = 31
  1450.       MonthLength.11   = 30
  1451.       MonthLength.12   = 31
  1452.       if (Year//4 == 0 & Year//100 > 0) | Year//400 == 0 Then MonthLength.2 = 29
  1453.  
  1454.       do I = (Month - 1) to 1 by -1
  1455.         DayCount = DayCount + MonthLength.I
  1456.       end
  1457.       if Option == 'D' then return DayCount + Day
  1458.       else return right(Year, 2)''right(DayCount + Day, 3, '0')
  1459.     end
  1460.     when Option == 'E' then do
  1461.       return right(Day, 2, '0')'/'right(Month, 2, '0')'/'right(Year, 2, '0')
  1462.     end
  1463.     when Option == 'I' then return J
  1464.     when (Option == 'M') | (Option == 'N') then do
  1465.       Select
  1466.         when Month ==  1 then Month = 'January'
  1467.         when Month ==  2 then Month = 'February'
  1468.         when Month ==  3 then Month = 'March'
  1469.         when Month ==  4 then Month = 'April'
  1470.         when Month ==  5 then Month = 'May'
  1471.         when Month ==  6 then Month = 'June'
  1472.         when Month ==  7 then Month = 'July'
  1473.         when Month ==  8 then Month = 'August'
  1474.         when Month ==  9 then Month = 'September'
  1475.         when Month == 10 then Month = 'October'
  1476.         when Month == 11 then Month = 'November'
  1477.         when Month == 12 then Month = 'December'
  1478.       end
  1479.       if Option == 'M' then return Month
  1480.       else return right(Day, 2, '0')' 'left(Month, 3)' 'Year
  1481.     end
  1482.     when Option == 'O' then return right(Year, 2, '0')'/'right(Month, 2, '0')'/'right(Day, 2, '0')
  1483.     when Option == 'S' then return right(Year, 4, '0')''right(Month, 2, '0')''right(Day, 2, '0')
  1484.     when Option == 'U' then return right(Month, 2, '0')'/'right(Day, 2, '0')'/'right(Year, 2, '0')
  1485.     when Option == 'W' then do
  1486.       J = J + 1
  1487.       Weekday = J - 7 * trunc(J / 7)
  1488.       Select
  1489.         when Weekday == 0 then return 'Sunday'
  1490.         when Weekday == 1 then return 'Monday'
  1491.         when Weekday == 2 then return 'Tuesday'
  1492.         when Weekday == 3 then return 'Wednesday'
  1493.         when Weekday == 4 then return 'Thursday'
  1494.         when Weekday == 5 then return 'Friday'
  1495.         when Weekday == 6 then return 'Saturday'
  1496.       end
  1497.     end
  1498.     otherwise return 0
  1499.   end
  1500. /**/
  1501.  
  1502. /***//*** DetermineDate (DD) ***/
  1503. DetermineDate:
  1504.   parse arg DD_Month, DD_Day, DD_Year
  1505.  
  1506.   if left(DD_Day, 2) == 32 then do
  1507.     if length(DD_Day) == 2 then DD_Day = MonthLength.DD_Month
  1508.     else DD_Day = MonthLength.DD_Month''right(DD_Day, 1)
  1509.   end
  1510.  
  1511.   DD_DateString = DD_Year''right(DD_Month, 2, '0')''right(strip(DD_Day, 'T', 'PN'), 2, '0')
  1512.  
  1513.   DD_Weekday = DateInfo('W', DD_DateString, 'S')
  1514.   if (right(DD_Day, 1) == 'N') & (DD_Weekday == 'Saturday') then do
  1515.     DD_NewDay = DateInfo('S', (DateInfo('I', DD_DateString, 'S') + 2), 'I')
  1516.     DD_Month = substr(DD_NewDay, 5, 2) - 0
  1517.     DD_Day = substr(DD_NewDay, 7, 2) - 0
  1518.   end
  1519.   else if (right(DD_Day, 1) == 'P') & (DD_Weekday == 'Saturday') then do
  1520.     DD_NewDay = DateInfo('S', (DateInfo('I', DD_DateString, 'S') - 1), 'I')
  1521.     DD_Month = substr(DD_NewDay, 5, 2) - 0
  1522.     DD_Day = substr(DD_NewDay, 7, 2) - 0
  1523.   end
  1524.   else if (right(DD_Day, 1) == 'N') & (DD_Weekday == 'Sunday') then do
  1525.     DD_NewDay = DateInfo('S', (DateInfo('I', DD_DateString, 'S') + 1), 'I')
  1526.     DD_Month = substr(DD_NewDay, 5, 2) - 0
  1527.     DD_Day = substr(DD_NewDay, 7, 2) - 0
  1528.   end
  1529.   else if (right(DD_Day, 1) == 'P') & (DD_Weekday == 'Sunday') then do
  1530.     DD_NewDay = DateInfo('S', (DateInfo('I', DD_DateString, 'S') - 2), 'I')
  1531.     DD_Month = substr(DD_NewDay, 5, 2) - 0
  1532.     DD_Day = substr(DD_NewDay, 7, 2) - 0
  1533.   end
  1534.   DD_Day = strip(DD_Day, 'T', 'PN')
  1535.  
  1536.   return DD_Month' 'DD_Day
  1537. /**/
  1538.  
  1539. /***//*** DetermineHost () ***/
  1540. DetermineHost:
  1541.   owner = ReadFile('ENV:Owner')
  1542.   if (pos('FINALWRITER', CurrentDir) > 0) | (left(CallHost, 6) == 'FINALW') then do
  1543.     App     = 'FW'
  1544.     AppName = 'FINALWRITER'
  1545.     if CallHost == 'REXX' then HostPort = substr(PortList, pos('FINALW.', PortList), 8)
  1546.     else HostPort = CallHost
  1547.     address value HostPort
  1548.     if owner == 'rgoertz' then do
  1549.       if CallHost == 'REXX' then CLEARDOC FORCE
  1550.       else do
  1551.         CLEARDOC
  1552.         if result == 1 then exit
  1553.       end
  1554.     end
  1555.     else do
  1556.       CLEARDOC
  1557.       if result == 1 then exit
  1558.     end
  1559.  
  1560.     GETDOCITEMPREFS Decimal; DecimalFormat = result
  1561.     DOCITEMPREFS Decimal Period
  1562.   end
  1563.   else if (pos('PAGESTREAM', CurrentDir) > 0) | (CallHost == 'PAGESTREAM') then do
  1564.     App     = 'PGS'
  1565.     AppName = 'PAGESTREAM'
  1566.     HostPort = 'PAGESTREAM'
  1567.     address value HostPort
  1568.   end
  1569.   else do
  1570.     call AddMsg('E', 'Unable to determine host!')
  1571.     call AddMsg('E', 'Make sure FWCalendar is called from Final Writer or PageStream.')
  1572.     call Cleanup
  1573.   end
  1574.  
  1575.   NameAndVersion = getclip('FWC'App'VersionInfo.txt')
  1576.   if NameAndVersion == '' then do
  1577.     address command 'list >PIPE:FWC 'AppName'#? lformat %N'
  1578.     ListOutput = ReadFile('PIPE:FWC')
  1579.     call openv('ListOutput')
  1580.       do while ~eofv('ListOutput')
  1581.         PgmName = readvln('ListOutput')
  1582.         if pos('.', PgmName) == 0 then leave
  1583.       end
  1584.     call closev('ListOutput')
  1585.     PgmVersion = PgmVer(PgmName)
  1586.     NameAndVersion = PgmName' 'PgmVersion
  1587. /* call AddMsg('I', 'PgmName='PgmName)               */
  1588. /* call AddMsg('I', 'PgmVersion='PgmVersion)         */
  1589. /* call AddMsg('I', 'NameAndVersion='NameAndVersion) */
  1590.     if PgmVersion == 'not' then do
  1591.       if App == 'FW' then do
  1592.         call open('Temp', CurrentDir''PgmName)
  1593.           /* Desired string at 325215 for v 5 created Jun 7 1996    */
  1594.           /* Desired string at 325365 for v 5.06 created Oct 9 1996 */
  1595.           /* Desired string at 333771 for FW97                      */
  1596.           FileOffset = 325200
  1597.           call seek('Temp', FileOffset, 'B')
  1598.           do until (EndPos ~= 0) | (PrevOffset = FileOffset)
  1599.             PrevOffset = FileOffset
  1600.             Chunk = readch('Temp', 10000)
  1601.             EndPos = pos('Created', Chunk)
  1602.             if EndPos == 0 then FileOffset = seek('Temp', -100, 'C')
  1603.           end
  1604.           if EndPos ~= 0 then do
  1605.             StartPos = lastpos('Final', Chunk, EndPos)
  1606.             EndPos = pos('00'x||'00'x, Chunk, StartPos)
  1607.             NameAndVersion = substr(Chunk, StartPos, EndPos - StartPos - 1)
  1608. /* call AddMsg('I', 'NameAndVersion2='NameAndVersion) */
  1609.           end
  1610.           else do
  1611.             FileOffset = 0
  1612.             call seek('Temp', FileOffset, 'B')
  1613.             do until (EndPos ~= 0) | (PrevOffset = FileOffset)
  1614.               PrevOffset = FileOffset
  1615.               Chunk = readch('Temp', 10000)
  1616.               EndPos = pos('FinalWriter 97', Chunk)
  1617.               if EndPos == 0 then FileOffset = seek('Temp', -100, 'C')
  1618.             end
  1619.             if EndPos ~= 0 then NameAndVersion = 'FinalWriter 97'
  1620.             else NameAndVersion = 'Final Writer - version unknown'
  1621.           end
  1622.         call close('Temp')
  1623.       end
  1624.       else if App == 'PGS' then do
  1625.         NameAndVersion = PgmName" - can't find version info"
  1626.       end
  1627.     end
  1628.     call setclip('FWC'App'VersionInfo.txt', NameAndVersion)
  1629.   end
  1630.   else do
  1631.     PgmName = word(NameAndVersion, 1)
  1632.     PgmVersion = subword(NameAndVersion, 2)
  1633.   end
  1634.  
  1635.   AppScreen = ''
  1636.   PubScreenApps = 'FrontPubScreen Publican MagicPubName'
  1637.   do i = 1 to words(PubScreenApps)
  1638.     interpret 'address command "'word(PubScreenApps, i)' >PIPE:FWC"'
  1639.     if RC > 0 then iterate
  1640.     AppScreen = readfile('PIPE:FWC')
  1641.     if AppScreen ~= '' then leave
  1642.   end
  1643.  
  1644.   return HostPort
  1645. /**/
  1646.  
  1647. /***//*** DoOptions (DO) ***/
  1648. DoOptions:
  1649.   if (DayType == 'Extended') & (BackgroundColor == '<'Clear$'>') then DO_PrintColor = Color.Extended
  1650.   else if (DayType == 'Extended') & (BackgroundColor ~= '<'Clear$'>') then DO_PrintColor = AltColor.Extended
  1651.  
  1652.   /***//* DoJulian & DoJulianLeft */
  1653.   if (DoJulian ~= '') | (DoJulianLeft ~= '') then do
  1654.     DO_JDay = right(DateInfo('J', JulianDay, 'I'), 3)
  1655.     if (Day <= 0) & (PrevMonth = 12) then DO_JDayLeft = right(365 + PrevLeapYear - DO_JDay, 3, '0')
  1656.     else DO_JDayLeft = right(365 + LeapYear - DO_JDay, 3, '0')
  1657.  
  1658.     if (DayType ~= 'Extended') & (BackgroundColor == '<'Clear$'>') then DO_PrintColor = Color.Julian
  1659.     else if (DayType ~= 'Extended') & (BackgroundColor ~= '<'Clear$'>') then DO_PrintColor = AltColor.Julian
  1660.  
  1661.     if DoJulian ~= '' then do
  1662.       DO_Text2Print = Text.Julian''DO_JDay
  1663.       if DoJulianLeft == DoJulian then DO_Text2Print = DO_Text2Print'/'DO_JDayLeft
  1664.       JID.Day = PrintOption(DoJulian)
  1665.     end
  1666.  
  1667.     if (DoJulianLeft ~= '') & (DoJulianLeft ~= DoJulian) then do
  1668.       DO_Text2Print = DO_JDayLeft
  1669.       JIDL.Day = PrintOption(DoJulianLeft)
  1670.     end
  1671.   end
  1672.   /**/
  1673.  
  1674. /***//* DoSunrise & DoSunset */
  1675.   if (DoSunRise ~= '') | (DoSunSet ~= '') then do
  1676.     SRSS$ = GetSRSS(JulianDay)
  1677.  
  1678.     if DoSunRise ~= '' then do
  1679.       if (DayType ~= 'Extended') & (BackgroundColor == '<'Clear$'>') then DO_PrintColor = Color.Sunrise
  1680.       else if (DayType ~= 'Extended') & (BackgroundColor ~= '<'Clear$'>') then DO_PrintColor = AltColor.Sunrise
  1681.       DO_Text2Print = Text.Sunrise''word(SRSS$, 1)
  1682.       if DoSunSet == DoSunRise then DO_Text2Print = DO_Text2Print'/'word(SRSS$, 3)
  1683.       SRID.Day = PrintOption(DoSunRise)
  1684.     end
  1685.  
  1686.     if (DoSunSet ~= '') & (DoSunSet ~= DoSunRise) then do
  1687.       if (DayType ~= 'Extended') & (BackgroundColor == '<'Clear$'>') then DO_PrintColor = Color.Sunset
  1688.       else if (DayType ~= 'Extended') & (BackgroundColor ~= '<'Clear$'>') then DO_PrintColor = AltColor.Sunset
  1689.       DO_Text2Print = Text.Sunset''word(SRSS$, 3)
  1690.       SSID.Day = PrintOption(DoSunSet)
  1691.     end
  1692.   end
  1693.   /**/
  1694.  
  1695. /***//* DoWeekNumber */
  1696.   if (DoWeekNumber ~= '') & (CurrentColumn = 0) then do
  1697.     if (DayType ~= 'Extended') & (BackgroundColor == '<'Clear$'>') then DO_PrintColor = Color.WeekNumber
  1698.     else if (DayType ~= 'Extended') & (BackgroundColor ~= '<'Clear$'>') then DO_PrintColor = AltColor.WeekNumber
  1699.     DO_WN = trunc((right(DateInfo('J', JulianDay, 'I'), 3) - YearOffset - 1)/7 + 1)
  1700.     DO_Text2Print = Text.WeekNumber''DO_WN
  1701.     WNID.Day = PrintOption(DoWeekNumber)
  1702.   end
  1703.   /**/
  1704.  
  1705.   /***//* DoImages */
  1706.   if DoImages == 1 then do
  1707.     if Image.Month.Day ~= '' then do
  1708.       ImageNumber = Image.Month.Day
  1709.       ImageDX = ImageDX.ImageNumber
  1710.       ImageDY = ImageDY.ImageNumber
  1711.       if ImageType.ImageNumber == '' then do
  1712.         DO_Cmd = Storage''GfxApp' >PIPE:FWC '
  1713.         DO_InsertPos = pos('%s', GfxCmd)
  1714.         DO_Cmd = DO_Cmd''left(GfxCmd, DO_InsertPos - 1)''ImageFile.ImageNumber''substr(GfxCmd, DO_InsertPos + 2)
  1715.         address command DO_Cmd
  1716.         DO_Template = GfxTemplate
  1717.         DO_InfoLine = ReadFile('PIPE:FWC')
  1718.         if DO_InfoLine ~= '' then do
  1719.           interpret "parse var DO_InfoLine "DO_Template
  1720.           DO_ImageType = upper(strip(ImgDT))
  1721.           DO_Width = strip(ImgWidth)
  1722.           DO_Height = strip(ImgHeight)
  1723.           if (datatype(DO_ImageType) ~= 'CHAR') | (datatype(DO_Width) ~= 'NUM') | (datatype(DO_Height) ~= 'NUM') then do
  1724.             call AddMsg('W', DO_InfoLine)
  1725.             Image.Month.Day = ''
  1726.           end
  1727.           else do
  1728.             ImageType.ImageNumber = DO_ImageType
  1729.             if DO_ImageType ~= 'POST' then do
  1730.               ImageWidth.ImageNumber = DO_Width / 72
  1731.               ImageHeight.ImageNumber = DO_Height / 72
  1732.               if (ImageWidth.ImageNumber > (BoxWidth * MaxImgWidth)) | (ImageHeight.ImageNumber > (BHeight * MaxImgHeight)) then do
  1733.                 EnlFactor = max(ImageWidth.ImageNumber / (BoxWidth * MaxImgWidth), ImageHeight.ImageNumber / (BHeight * MaxImgHeight))
  1734.                 ImageWidth.ImageNumber  = ImageWidth.ImageNumber / EnlFactor
  1735.                 ImageHeight.ImageNumber = ImageHeight.ImageNumber / EnlFactor
  1736.               end
  1737.             end
  1738.           end
  1739.         end
  1740.       end
  1741.  
  1742.       if ImageType.ImageNumber ~= '' then do
  1743.         if App == 'FW' then do
  1744.           if ImageWidth.ImageNumber == 0 then do
  1745.             INSERTIMAGE ImageFile.ImageNumber POSITION 1 '-1' '-1' '-1' '-1'
  1746.             ImageID.Day = result
  1747.             GETOBJECTCOORDS ImageID.Day
  1748.             parse var result . . . ImageWidth.ImageNumber ImageHeight.ImageNumber
  1749.             if (ImageWidth.ImageNumber > (BoxWidth * MaxImgWidth)) | (ImageHeight.ImageNumber > (BHeight * MaxImgHeight)) then do
  1750.               EnlFactor = max(ImageWidth.ImageNumber / (BoxWidth * MaxImgWidth), ImageHeight.ImageNumber / (BHeight * MaxImgHeight))
  1751.               ImageWidth.ImageNumber  = ImageWidth.ImageNumber / EnlFactor
  1752.               ImageHeight.ImageNumber = ImageHeight.ImageNumber / EnlFactor
  1753.             end
  1754.             DELETEOBJECT ImageID.Day
  1755.           end
  1756.           Image.Left = BoxLeft + (BoxWidth - ImageWidth.ImageNumber)/2 + ImageDX
  1757.           Image.Top  = BoxTop + (BHeight - ImageHeight.ImageNumber)/2 + ImageDY
  1758.           INSERTIMAGE ImageFile.ImageNumber POSITION 1 Image.Left Image.Top ImageWidth.ImageNumber ImageHeight.ImageNumber
  1759.           ImageID.Day = result
  1760.           OBJECTTOBACK ImageID.Day
  1761.         end
  1762.         else if App == 'PGS' then do
  1763.           DO_ImgType = ImageType.ImageNumber
  1764.           if PGSFilter.DO_ImgType == '' then PGSFilter.DO_ImgType = DO_ImgType
  1765.           if ImageWidth.ImageNumber == 0 then do
  1766.             PLACEGRAPHIC FILE ImageFile.ImageNumber FILTER PGSFilter.DO_ImgType WINDOW winName
  1767.             ImageID.Day = result
  1768.             if ImageType.ImageNumber == 'POST' then GETDRAWING POSITION Image OBJECTID ImageID.Day WINDOW winName
  1769.             else GETPICTURE POSITION Image OBJECTID ImageID.Day WINDOW winName
  1770.             DELETEOBJECT OBJECTID ImageID.Day WINDOW winName
  1771.             ImageWidth.ImageNumber = Image.Right - Image.Left
  1772.             ImageHeight.ImageNumber = Image.Bottom - Image.Top
  1773.             if (ImageWidth.ImageNumber > (BoxWidth * MaxImgWidth)) | (ImageHeight.ImageNumber > (BHeight * MaxImgHeight)) then do
  1774.               EnlFactor = max(ImageWidth.ImageNumber / (BoxWidth * MaxImgWidth), ImageHeight.ImageNumber / (BHeight * MaxImgHeight))
  1775.               ImageWidth.ImageNumber  = ImageWidth.ImageNumber / EnlFactor
  1776.               ImageHeight.ImageNumber = ImageHeight.ImageNumber / EnlFactor
  1777.             end
  1778.           end
  1779.           Image.Left = BoxLeft + (BoxWidth - ImageWidth.ImageNumber)/2 + ImageDX
  1780.           Image.Top  = BoxTop + (BHeight - ImageHeight.ImageNumber)/2 + ImageDY
  1781.           PLACEGRAPHIC FILE ImageFile.ImageNumber FILTER PGSFilter.DO_ImgType AT Image.Left Image.Top WINDOW winName
  1782.           ImageID.Day = result
  1783.           if ImageType.ImageNumber == 'POST' then EDITDRAWING POSITION Image.Left Image.Top (Image.Left + ImageWidth.ImageNumber) (Image.Top + ImageHeight.ImageNumber) OBJECTID ImageID.Day WINDOW winName
  1784.           else EDITPICTURE POSITION Image.Left Image.Top (Image.Left + ImageWidth.ImageNumber) (Image.Top + ImageHeight.ImageNumber) OBJECTID ImageID.Day WINDOW winName
  1785.           SENDTOBACK OBJECTID ImageID.Day WINDOW winName
  1786.         end
  1787.       end
  1788.     end
  1789.   end
  1790.   /**/
  1791.  
  1792. /***//* DoPhases */
  1793.   if Day < 1 then do
  1794.     DO_PrintColor = Color.Extended
  1795.     DO_MoonMonth = PrevMonth
  1796.     DO_MoonYear = PrevYear
  1797.   end
  1798.   else if Day > MonthLength.Month then do
  1799.     DO_PrintColor = Color.Extended
  1800.     DO_MoonMonth = NextMonth
  1801.     DO_MoonYear = NextYear
  1802.   end
  1803.   else do
  1804.     DO_PrintColor = Color.Moon
  1805.     DO_MoonMonth = Month
  1806.     DO_MoonYear = EnteredYear
  1807.   end
  1808.   if (DoPhases ~= '') & (MoonPhase.DO_MoonYear.DO_MoonMonth.PrintDay ~= '') then do
  1809.     select
  1810.       when right(DoPhases, 1) == 'L' then DO_MoonLeft = BoxLeft + (MoonRadius * 1.2)
  1811.       when right(DoPhases, 1) == 'C' then DO_MoonLeft = BoxLeft + BoxWidth / 2
  1812.       when right(DoPhases, 1) == 'R' then DO_MoonLeft = BoxLeft + BoxWidth - (MoonRadius * 1.2)
  1813.     end
  1814.     if left(DoPhases, 1) == 'T' then DO_DX = MoonRadius * 1.2
  1815.     else if left(DoPhases, 1) == 'B' then DO_DX = BHeight - (MoonRadius * 1.2)
  1816.     MoonID.Day = DrawMoon(MoonPhase.DO_MoonYear.DO_MoonMonth.PrintDay, DO_MoonLeft, BoxTop + DO_DX, DO_PrintColor)
  1817.     if left(DoPhases, 1) == 'T' then MoonID.Day = 0
  1818.   end
  1819.   /**/
  1820.  
  1821. /***//* DoHistory */
  1822.   if DoHistory ~= 0 then do
  1823.     DO_Start = pos('|'||PrintDay, RandomFile)
  1824.     if DO_Start ~= 0 then do
  1825.       DO_End = pos('|'||'0a'x, RandomFile, DO_Start)
  1826.       if DO_End == 0 then DO_End = length(RandomFile)
  1827.       DO_RandomFile = substr(RandomFile, DO_Start, DO_End - DO_Start - 1)
  1828.       RandomCount = length(DO_RandomFile) - length(compress(DO_RandomFile, '|'))
  1829.       if RandomCount == 1 then RandomLine = 1
  1830.       else RandomLine = trunc(randu(time(s)*date('I')) * RandomCount) + 1
  1831.       call openv('DO_RandomFile')
  1832.       if RandomLine > 1 then call readvln('DO_RandomFile', RandomLine - 1)
  1833.       call PrintHighlight(strip(substr(readvln('DO_RandomFile'), 4)), 'History')
  1834.       call closev('DO_RandomFile')
  1835.     end
  1836.   end
  1837. /**/
  1838.  
  1839. /***//* DoRandom */
  1840.   if DoRandom ~= 0 then do
  1841.     if RandomCount >= Monthlength.Month then do
  1842.       do until pos('|'RandomLine'|', UsedRandoms) == 0
  1843.         RandomLine = trunc(randu(time(s)*date('I')) * RandomCount) + 1
  1844.       end
  1845.       UsedRandoms = UsedRandoms'|'RandomLine'|'
  1846.     end
  1847.     else RandomLine = trunc(randu(time(s)*date('I')) * RandomCount) + 1
  1848.     call seekv('RandomFile', 0, 'B')
  1849.     if RandomLine > 1 then call readvln('RandomFile', RandomLine - 1)
  1850.     call PrintHighlight(substr(readvln('RandomFile'), 2), 'Random')
  1851.   end
  1852. /**/
  1853.  
  1854.   return
  1855. /**/
  1856.  
  1857. /***//*** DoSetupReq_BGUI () ***/
  1858. DoSetupReq_BGUI:
  1859.   grp.0 = 'obj.bottomleft_'
  1860.   grp.1 = 'obj.bottomcenter_'
  1861.   grp.2 = 'obj.bottomright_'
  1862.   grp.3 = 'obj.topcenter_'
  1863.   grp.4 = 'obj.topright_'
  1864.  
  1865.   Action.0 = 'MX_EnableButton'
  1866.   Action.1 = 'MX_DisableButton'
  1867.  
  1868.   DoBothS  = ''
  1869.   DoBothJ  = ''
  1870.  
  1871.   UCMN = upper(CurrentMiscName)
  1872.   if (UCMN == 'GFXAPPPATH') | (UCMN == 'SUNCALCPATH') | (UCMN == 'GFXAPP') then VarReqGad = 1
  1873.   else VarReqGad = 0
  1874.  
  1875.   if (PrefsName == 'Default') & (PrefsFile ~= 'Default') then DisplayName = PrefsFile
  1876.   else DisplayName = PrefsName
  1877.  
  1878.   do DSR_Posn = 1 + (PhaseLib ~= 1) to 5 + 3 * exists(Storage'suncalc')
  1879.     interpret 'DoVariable = "Do'Do.DSR_Posn'"'
  1880.     if value(DoVariable) == 0 then interpret DoVariable " = ''"
  1881.     if value(DoVariable) ~= '' then do
  1882.       interpret DoVariable' = right(value(DoVariable), 2, "B")'
  1883.       DSR_Grp = translate(left(value(DoVariable), 1), '02', 'BT') + translate(right(value(DoVariable), 1), '012', 'LCR')
  1884.       GadSel.DSR_Grp.DSR_Posn = 1
  1885.       DSR_Sel.DSR_Grp = DSR_Posn
  1886.     end
  1887.   end
  1888.  
  1889.   do DSR_Grp = 0 to GroupCount
  1890.     if (GadSel.DSR_Grp.SunsetPosn == GadSel.DSR_Grp.SunrisePosn) & (GadSel.DSR_Grp.SunsetPosn == 1) then do
  1891.        GadSel.DSR_Grp.SunsetPosn  = 0
  1892.        GadSel.DSR_Grp.SunrisePosn = 0
  1893.        GadSel.DSR_Grp.BothSPosn   = 1
  1894.        DSR_Sel.DSR_Grp = BothSPosn
  1895.     end
  1896.     else if (GadSel.DSR_Grp.JulianPosn == GadSel.DSR_Grp.JulianLeftPosn) & (GadSel.DSR_Grp.JulianPosn == 1) then do
  1897.        GadSel.DSR_Grp.JulianPosn     = 0
  1898.        GadSel.DSR_Grp.JulianLeftPosn = 0
  1899.        GadSel.DSR_Grp.BothJPosn      = 1
  1900.        DSR_Sel.DSR_Grp = BothJPosn
  1901.     end
  1902.   end
  1903.  
  1904.   call bguilist('monthlist_',January$,February$,March$,April$,May$,June$,July$,August$,September$,October$,November$,December$)
  1905.   call bguilist('mxopts_',None$,Phases$,Weeknumber$,Julian$,JulLeft$,JulJulLeft$,Sunrise$,Sunset$,RiseSet$)
  1906.   call bguilist('mxopts2_',None$,Phases$,Weeknumber$,Julian$,JulLeft$,JulJulLeft$,Sunrise$,Sunset$,RiseSet$,History$,Random$)
  1907.   if App == 'FW' then do
  1908.     call bguilist('calendartypelist_',SingleMonth$,WholeYear$)
  1909.     MonthYearGads = bguihgroup(,
  1910.       bguicycle('monthchoice_',,'monthlist_','P')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  1911.       bguistring('yearchoice_',,Year,5)bguilayout(LGO_FixMinHeight, 1))
  1912.   end
  1913.   else do
  1914.     call bguilist('calendartypelist_',SingleMonth$,MultiMonth$,WholeYear$)
  1915.     MonthYearGads = bguihgroup(,
  1916.       bguicycle('monthchoice_',,'monthlist_','P')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  1917.       bguicycle('endmonthchoice_',,'monthlist_','P')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  1918.       bguistring('yearchoice_',,Year,5)bguilayout(LGO_FixMinHeight, 1))
  1919.   end
  1920.  
  1921.   /***//*** GUI Description ***/
  1922.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  1923.   g=bguivgroup(,
  1924.     bguiinfo('dummy_',,esc||'c'DisplayName)bguilayout(LGO_FixMinHeight, 1)||,
  1925.     bguimx('mainswitcher_',,bguilist('mainpnames_',OptLayout$,Variables$,Top$,Bottom$),'T')bguilayout(LGO_FixMinHeight,1)||,
  1926.     bguipages('mainpages_',,
  1927.       bguivgroup(,
  1928.         bguihgroup(,
  1929.           bguivgroup(,
  1930.             bguicheckbox('minicals_',MiniCals$, DoMiniCals)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  1931.             bguicheckbox('highlights_',Highlights$, DoHighlights)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  1932.             bguicheckbox('images_',Images$, DoImages)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  1933.             bguicheckbox('dateboxes_',BoxDates$, DoDateBox)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  1934.           )||,
  1935.           bguivarspace(10)||,
  1936.           bguivgroup(,
  1937.             bguicheckbox('extended_',Extended$, DoExtended)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  1938.             bguicheckbox('toplong_',TopLong$, DoTopExtraWk)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  1939.             bguicheckbox('notebox_',NoteBox$, DoNoteBox)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  1940.           ),
  1941.         ,-2,'F',Options$)||,
  1942.         bguivgroup(,
  1943.           bguihgroup(,
  1944.             bguivarspace(40)||,
  1945.             bguistring('topmargin_',,Margin.Top,8)bguilayout(LGO_FixMinHeight, 1)bguilayout(LGO_Weight,20)||,
  1946.             bguivarspace(40),
  1947.           )||,
  1948.           bguihgroup(,
  1949.             bguivarspace(20)||,
  1950.             bguistring('leftmargin_',,Margin.Left,8)bguilayout(LGO_FixMinHeight, 1,LGO_Weight,20)||,
  1951.             bguicycle('orientation_',,bguilist('orientlist_',Wide$,Tall$))bguilayout(LGO_FixMinHeight, 1,LGO_Weight,20)||,
  1952.             bguistring('rightmargin_',,Margin.Right,8)bguilayout(LGO_FixMinHeight, 1,LGO_Weight,20)||,
  1953.             bguivarspace(20),
  1954.           )||,
  1955.           bguihgroup(,
  1956.             bguivarspace(40)||,
  1957.             bguistring('bottommargin_',,Margin.Bottom,8)bguilayout(LGO_FixMinHeight, 1,LGO_Weight,20)||,
  1958.             bguivarspace(40),
  1959.           ),
  1960.         ,-2,'F',OrientMarg$),
  1961.       )||,
  1962.       bguivgroup(,
  1963.         bguihgroup(,
  1964.           bguicycle('fontvar_',,'FontVarName','P')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1)||,
  1965.           bguistring('fontvalue_',,value(CurrentFontName),256)bguilayout(LGO_FixMinHeight,1)||,
  1966.           bguiibutton('addfont_','B','P')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1),
  1967.         ,-2,'F',Fonts$)||,
  1968.         bguivgroup(,
  1969.           bguihgroup(,
  1970.             bguicycle('colorvar_',,'ColorVarName','P')bguilayout(LGO_FixMinHeight, 1)||,
  1971.             bguicycle('colorlist_',,'ColorList','P')bguilayout(LGO_FixMinHeight, 1),
  1972.           )||,
  1973.           bguihgroup(,
  1974.             bguivarspace(1)||,
  1975.             bguicheckbox('matchcolors_',MatchColors$, DoMatchColors)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  1976.           )||,
  1977.           bguihgroup(,
  1978.             bguivarspace(1)||,
  1979.             bguicheckbox('dailycolors_',DailyColors$, DoDailyColors)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  1980.           ),
  1981.         ,-2,'F',Colors$)||,
  1982.         bguivgroup(,
  1983.           bguihgroup(,
  1984.             bguivarspace(40)||,
  1985.             bguibutton('sethighlights_',HighlightEd$)bguilayout(LGO_FixMinHeight, 1,LGO_Weight,20)||,
  1986.             bguivarspace(40),
  1987.           )||,
  1988.           bguihgroup(,
  1989.             bguicycle('currentvar_',,'MiscVarName','P')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1)||,
  1990.             bguistring('currentvalue_',,VarVal,256)bguilayout(LGO_FixMinHeight,1)||,
  1991.             bguiibutton('addvar_','B','F')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1),
  1992.           ),
  1993.         ,-2,'F',MiscVar$),
  1994.       ,-2)||,
  1995.       bguihgroup(,
  1996.         bguivarspace(40)||,
  1997.         bguivgroup(,
  1998.           bguimx('topcenter_',Top$||'0a'x||Center$,'mxopts_','R')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  1999.         ,-3,'F')||,
  2000.         bguivgroup(,
  2001.           bguimx('topright_',Top$||'0a'x||Right$,'mxopts_','R')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  2002.         ,-3,'F'),
  2003.       )||,
  2004.       bguihgroup(,
  2005.         bguivgroup(,
  2006.           bguimx('bottomleft_',Bottom$||'0a'x||Left$,'mxopts_','R')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  2007.         ,-3,'F')||,
  2008.         bguivgroup(,
  2009.           bguimx('bottomcenter_',Bottom$||'0a'x||Center$,'mxopts2_','R')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  2010.         ,-3,'F')||,
  2011.         bguivgroup(,
  2012.           bguimx('bottomright_',Bottom$||'0a'x||Right$,'mxopts_','R')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  2013.         ,-3,'F'),
  2014.       ),
  2015.     )||,
  2016.     MonthYearGads||,
  2017.     bguihgroup(,
  2018.       bguicycle('calendartype_',,'calendartypelist_','P')bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  2019.       bguibutton('go_',Go$)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  2020.       bguivarspace(2)||,
  2021.       bguibutton('reset_',Reset$)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  2022.       bguibutton('load_',Load$)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  2023.       bguibutton('saveas_',SaveAs$)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1)||,
  2024.       bguivarspace(2)||,
  2025.       bguibutton('cancel_',Cancel$)bguilayout(LGO_FixMinWidth, 1,LGO_FixMinHeight, 1),
  2026.     ),
  2027.   ,'-3','-3')
  2028.   /**/
  2029.  
  2030.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  2031.   winID=bguiwindow(VarGUITitle$,g,-1,-1,,AppScreen)
  2032.  
  2033.   if App == 'FW' then nop
  2034.   else if App == 'PGS' then do
  2035.     FontGroup=bguivgroup(bguilistview('fontlistview_',,'FontList'))
  2036.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  2037.     FontwinID=bguiwindow(SelectFont$':',FontGroup,20,50,,AppScreen)
  2038.   end
  2039.  
  2040.   do DSR_Grp = 0 to GroupCount
  2041.     interpret 'call bguiset('grp.DSR_Grp',winID,MX_Active,DSR_Sel.DSR_Grp)'
  2042.     call ControlMX(DSR_Grp, DSR_Sel.DSR_Grp)
  2043.     if PhaseLib ~= 1 then interpret 'call bguiset('grp.DSR_Grp',winID,MX_DisableButton,1)'
  2044.     if ~exists(Storage'suncalc') then interpret 'call bguiset('grp.DSR_Grp',winID,MX_DisableButton,6,MX_DisableButton,7,MX_DisableButton,8)'
  2045.   end
  2046.  
  2047.   if App == 'PGS' then call bguiset(obj.endmonthchoice_, winID, GA_Disabled, 1)
  2048.   call bguiset(obj.addvar_, winID, GA_Disabled, ~VarReqGad)
  2049.   call bguiset(obj.orientation_,winID,CYC_Active,OrientChoice)
  2050.   call bguiset(obj.monthchoice_,winID,CYC_Active,CalMonth-1)
  2051.   call bguiset(obj.colorlist_,winID,CYC_Active,max(0, MemberID(Value(CurrentColorName),'ColorList')))
  2052.   CurrentColor = bguiget(obj.colorlist_, CYC_Active)
  2053.   call bguiset(obj.currentvar_,,BT_Key,'09'x)
  2054.   call bguiset(obj.currentvalue_,,BT_Key,'0d'x)
  2055.   call bguiset(obj.images_,winID,GA_Disabled,~exists(Storage''GfxApp))
  2056.   call bguiaddmap(obj.mainswitcher_,obj.mainpages_,MX_Active,PAGE_Active)
  2057.   call bguiwintabcycleorder(winID,obj.topmargin_||obj.leftmargin_||obj.rightmargin_||obj.bottommargin_)
  2058.   if DoExtended == 1 then do
  2059.     call bguiset(obj.toplong_,winID, GA_Selected, 0, GA_Disabled, 1)
  2060.     DoTopExtraWk = 0
  2061.     call bguiset(obj.notebox_,winID, GA_Selected, 0, GA_Disabled, 1)
  2062.     DoNoteBox = 0
  2063.   end
  2064.  
  2065.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  2066.   DSR_Success = bguiwinopen(winID)
  2067.   if DSR_Success == 0 then bguierror(12)
  2068.  
  2069.   call CloseBusy(Req)
  2070.  
  2071.   /***//*** GUI Action Loop ***/
  2072.   Done  = 0
  2073.   Reset = 0
  2074.   do while 1
  2075.     call bguiwinwaitevent(winID,'ID')
  2076.     select
  2077.       when (id == id.cancel_) | (id == id.winclose) then Reset = 2
  2078.     /***//*** ResetGad ***/
  2079.       when id == id.reset_ then do
  2080.         Reset = 1
  2081.         PrefsFile = 'Default'
  2082.         call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  2083.       end
  2084.     /**/
  2085.  
  2086.     /***//*** LoadGad ***/
  2087.       when id == id.load_ then do
  2088.         CurrentPrefs = PrefsFile
  2089.         PrefsFile = bguifilereq(ScriptDir''"FWCalendar.prefs", SelectFile$':', winID,DOPATTERNS,'#?.(data|prefs)')
  2090.         if PrefsFile == '' then PrefsFile = CurrentPrefs
  2091.         else do
  2092.           if exists(PrefsFile) then do
  2093.             Reset = 1
  2094.             call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  2095.           end
  2096.           else do
  2097.             call bguireq(PrefsFile' 'CantFind$'...','*'OK$,'FWCalendar 'Notice$,winID)
  2098.             PrefsFile = CurrentPrefs
  2099.           end
  2100.         end
  2101.       end
  2102.     /**/
  2103.  
  2104.     /***//*** SaveAsGad ***/
  2105.       when id == id.saveas_ then do
  2106.         DSR_File = bguifilereq(ScriptDir'FWCalendar.prefs', SelectPrefs$)
  2107.         if DSR_File ~= '' then do
  2108.           PrefsFile = DSR_File
  2109.           call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  2110.         end
  2111.       end
  2112.     /**/
  2113.  
  2114.     /***//*** MiniCalsGad ***/
  2115.       when id == id.minicals_ then     DoMiniCals = sign(bguiget(obj.minicals_, GA_Selected))
  2116.     /**/
  2117.  
  2118.     /***//*** HighlightsGad ***/
  2119.       when id == id.highlights_ then   DoHighlights = sign(bguiget(obj.highlights_, GA_Selected))
  2120.     /**/
  2121.  
  2122.     /***//*** ExtendedGad ***/
  2123.       when id == id.extended_ then do
  2124.         DoExtended = sign(bguiget(obj.extended_, GA_Selected))
  2125.         if DoExtended == 1 then do
  2126.           call bguiset(obj.toplong_,winID, GA_Selected, 0, GA_Disabled, 1)
  2127.           DoTopExtraWk = sign(bguiget(obj.toplong_, GA_Selected))
  2128.           call bguiset(obj.notebox_,winID, GA_Selected, 0, GA_Disabled, 1)
  2129.           DoNoteBox = sign(bguiget(obj.notebox_, GA_Selected))
  2130.         end
  2131.         else do
  2132.           call bguiset(obj.toplong_,winID, GA_Disabled, 0)
  2133.           call bguiset(obj.notebox_,winID, GA_Disabled, 0)
  2134.         end
  2135.       end
  2136.     /**/
  2137.  
  2138.     /***//*** Checkbox & Margin Gads ***/
  2139.       when id == id.toplong_ then      DoTopExtraWk = sign(bguiget(obj.toplong_, GA_Selected))
  2140.       when id == id.notebox_ then      DoNoteBox = sign(bguiget(obj.notebox_, GA_Selected))
  2141.       when id == id.dateboxes_ then    DoDateBox = sign(bguiget(obj.dateboxes_, GA_Selected))
  2142.       when id == id.images_ then       DoImages = sign(bguiget(obj.images_, GA_Selected))
  2143.       when id == id.matchcolors_ then  DoMatchColors = sign(bguiget(obj.matchcolors_, GA_Selected))
  2144.       when id == id.dailycolors_ then  DoDailyColors = sign(bguiget(obj.dailycolors_, GA_Selected))
  2145.       when id == id.topmargin_ then    Margin.Top = bguiget(obj.topmargin_, STRINGA_TextVal)
  2146.       when id == id.leftmargin_ then   Margin.Left = bguiget(obj.leftmargin_, STRINGA_TextVal)
  2147.       when id == id.rightmargin_ then  Margin.Right = bguiget(obj.rightmargin_, STRINGA_TextVal)
  2148.       when id == id.bottommargin_ then Margin.Bottom = bguiget(obj.bottommargin_, STRINGA_TextVal)
  2149.       when id == id.orientation_ then do
  2150.         if bguiget(obj.orientation_,CYC_Active) == 0 then Orientation = 'Wide'
  2151.         else Orientation = 'Tall'
  2152.       end
  2153.     /**/
  2154.  
  2155.     /***//*** FontValueGad ***/
  2156.       when id == id.fontvalue_ then do
  2157.         call bguireq('1b'x||"c"MustUse$,"*"OK$,'',winID)
  2158.         call bguiset(obj.fontvalue_, winID,STRINGA_TextVal, value(CurrentFontName))
  2159.       end
  2160.     /**/
  2161.  
  2162.     /***//*** AddFontGad ***/
  2163.       when id == id.addfont_ then do
  2164.         if App == 'FW' then do
  2165.           FontFile = bguifilereq(CurrentDir'FWFonts/SWOLFonts/', SelectFont$':', winID,,'#?')
  2166.           if FontFile ~= '' then call bguiset(obj.fontvalue_, winID, STRINGA_TextVal,FontFile)
  2167.         end
  2168.         else if App == 'PGS' then do
  2169.           call bguiwinbusy(winID)
  2170.           call bguiwinopen(FontwinID)
  2171.           do while 1
  2172.             call bguiwinwaitevent(FontwinID,'ID')
  2173.             if id = id.winclose then leave
  2174.             if id = id.fontlistview_ then do
  2175.               call bguiset(obj.fontvalue_, winID, STRINGA_TextVal,bguiget(obj.fontlistview_, LISTV_LastClicked))
  2176.               leave
  2177.             end
  2178.           end
  2179.           call bguiwinclose(FontwinID)
  2180.           call bguiwinready(winID)
  2181.         end
  2182.       end
  2183.     /**/
  2184.  
  2185.     /***//*** FontVarGad ***/
  2186.       when id == id.fontvar_ then do
  2187.         interpret CurrentFontName" = "QuoteIt(bguiget(obj.fontvalue_, STRINGA_TextVal))
  2188.         CurrentFontName = value('FontVarName.'bguiget(obj.fontvar_, CYC_Active))
  2189.         call bguiset(obj.fontvalue_,winID,STRINGA_TextVal,Value(CurrentFontName))
  2190.       end
  2191.     /**/
  2192.  
  2193.     /***//*** AddVarGad ***/
  2194.       when id == id.addvar_ then do
  2195.         if (upper(CurrentMiscName) == 'GFXAPPPATH') | (upper(CurrentMiscName) == 'GFXAPP') then do
  2196.           Value = bguifilereq(GfxAppPath, SelectApp$':', winID,,'#?')
  2197.           if Value ~= '' then do
  2198.             GPath = pathpart(Value)
  2199.             GFile = filepart(Value)
  2200.             if upper(CurrentMiscName) == 'GFXAPPPATH' then call bguiset(obj.currentvalue_, winID, STRINGA_TextVal,GPath)
  2201.             else call bguiset(obj.currentvalue_, winID, STRINGA_TextVal,GFile)
  2202.             interpret 'GfxAppPath = 'QuoteIt(GPath)
  2203.             interpret 'GfxApp = 'QuoteIt(GFile)
  2204.             if (exists(GfxAppPath''GfxApp)) & (~exists(Storage''GfxApp)) then do
  2205.               address command 'copy 'GfxAppPath''GfxApp' 'Storage
  2206.               call bguiset(obj.images_,winID,GA_Disabled,~exists(Storage''GfxApp))
  2207.             end
  2208.           end
  2209.         end
  2210.  
  2211.         else if (upper(CurrentMiscName) == 'SUNCALCPATH') then do
  2212.           Value = bguifilereq(CurrentDir, SelectApp$':', winID,,'#?')
  2213.           if (Value ~= '') & (upper(right(Value, 7)) == 'SUNCALC') then do
  2214.             Value = pathpart(Value)
  2215.             call bguiset(obj.currentvalue_, winID, STRINGA_TextVal,Value)
  2216.             interpret 'SuncalcPath = 'QuoteIt(Value)
  2217.             if (exists(SuncalcPath'suncalc')) & (~exists(Storage'Suncalc')) then do
  2218.               address command 'copy 'SunCalcPath'suncalc 'Storage
  2219.               do i = 0 to GroupCount
  2220.                 interpret 'call bguiset('grp.i',winID,MX_EnableButton,6,MX_EnableButton,7,MX_EnableButton,8)'
  2221.               end
  2222.             end
  2223.           end
  2224.         end
  2225.  
  2226.         else if left(upper(CurrentMiscName), 11) == 'IMAGECLASS.' then do
  2227.           Value = bguifilereq(CurrentDir, SelectImage$':', winID,,'#?')
  2228.           if Value ~= '' then do
  2229.             call bguiset(obj.currentvalue_, winID, STRINGA_TextVal,Value)
  2230.             IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  2231.             interpret 'ImageFile.'IC' = Value'
  2232.           end
  2233.         end
  2234.       end
  2235.     /**/
  2236.  
  2237.     /***//*** ColorVarGad ***/
  2238.       when id == id.colorvar_ then do
  2239.         interpret CurrentColorName' = "'value('ColorList.'bguiget(obj.colorlist_, CYC_Active))'"'
  2240.         CurrentColorName = value('ColorVarName.'bguiget(obj.colorvar_, CYC_Active))
  2241.         call bguiset(obj.colorlist_,winID,CYC_Active,max(0, MemberID(Value(CurrentColorName),'ColorList')))
  2242.         CurrentColor = bguiget(obj.colorlist_, CYC_Active)
  2243.       end
  2244.     /**/
  2245.  
  2246.     /***//*** ColorListGad ***/
  2247.       when id == id.colorlist_ then do
  2248.         if (pos('BACKGROUND.', upper(CurrentColorName)) == 0) & (bguiget(obj.colorlist_, CYC_Active) == ColorList.Count - 1) then do
  2249.           call bguireq('1b'x||"c"NotClear$,"*"OK$,'',winID)
  2250.           call bguiset(obj.colorlist_, winID, CYC_Active, CurrentColor)
  2251.         end
  2252.       end
  2253.     /**/
  2254.  
  2255.     /***//*** CurrentVarGad ***/
  2256.       when id == id.currentvar_ then do
  2257.         Value = bguiget(obj.currentvalue_, STRINGA_TextVal)
  2258.         if upper(left(CurrentMiscName, pos('.', CurrentMiscName))) == 'IMAGECLASS.' then do
  2259.           IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  2260.           interpret 'ImageFile.'IC' = Value'
  2261.         end
  2262.         else do
  2263.           if datatype(Value) == 'CHAR' then Value = QuoteIt(Value)
  2264.           interpret CurrentMiscName' = 'Value
  2265.         end
  2266.         CurrentMiscName = value('MiscVarName.'bguiget(obj.currentvar_, CYC_Active))
  2267.         if upper(left(CurrentMiscName, pos('.', CurrentMiscName))) == 'IMAGECLASS.' then do
  2268.           IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  2269.           call bguiset(obj.currentvalue_,winID,STRINGA_TextVal,value('ImageFile.IC'))
  2270.         end
  2271.         else call bguiset(obj.currentvalue_,winID,STRINGA_TextVal,Value(CurrentMiscName))
  2272.         UCMN = upper(CurrentMiscName)
  2273.         if (UCMN == 'GFXAPPPATH') | (UCMN == 'SUNCALCPATH') | (UCMN == 'GFXAPP') | (left(UCMN, 11) == 'IMAGECLASS.') then VarReqGad = 1
  2274.         else VarReqGad = 0
  2275.         call bguiset(obj.addvar_, winID, GA_Disabled, ~VarReqGad)
  2276.       end
  2277.     /**/
  2278.  
  2279.     /***//*** CurrentValueGad ***/
  2280.       when id == id.currentvalue_ then do
  2281.         if (upper(CurrentMiscName) == 'GFXAPPPATH') | (upper(CurrentMiscName) == 'GFXAPP') | (upper(CurrentMiscName) == 'SUNCALCPATH') then do
  2282.           call bguireq('1b'x||"c"MustUse$,"*"OK$,'',winID)
  2283.           call bguiset(obj.currentvalue_, winID,STRINGA_TextVal, value(CurrentMiscName))
  2284.         end
  2285.         else if left(upper(CurrentMiscName), 11) == 'IMAGECLASS.' then do
  2286.           if bguiget(obj.currentvalue_, STRINGA_TextVal) ~= '' then do
  2287.             call bguireq('1b'x||"c"MustUse$,"*"OK$,'',winID)
  2288.             IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  2289.             call bguiset(obj.currentvalue_, winID,STRINGA_TextVal, ImageFile.IC)
  2290.           end
  2291.         end
  2292.       end
  2293.     /**/
  2294.  
  2295.     /***//*** SetHighlightsGad ***/
  2296.       when id == id.sethighlights_ then do
  2297.         EH_SelectMonth = bguiget(obj.monthchoice_, CYC_Active) + 1
  2298.         call bguiwinbusy(winID)
  2299.         do until DS_Done == 1
  2300.           DS_Done = EditHighlight_BGUI()
  2301.         end
  2302.         call bguiwinready(winID)
  2303.       end
  2304.     /**/
  2305.  
  2306.     /***//*** CalendarTypeGad ***/
  2307.     when id == id.calendartype_ then do
  2308.       CalType = bguiget(obj.calendartype_, CYC_Active) + 1
  2309.       if (App == 'FW') & (CalType == 2) then CalType = 3
  2310.       if CalType == 1 then do
  2311.         call bguiset(obj.monthchoice_, winID, GA_Disabled, 0)
  2312.         if App == 'PGS' then call bguiset(obj.endmonthchoice_, winID, GA_Disabled, 1)
  2313.       end
  2314.       else if CalType == 2 then do
  2315.         call bguiset(obj.monthchoice_, winID, GA_Disabled, 0)
  2316.         call bguiset(obj.endmonthchoice_, winID, GA_Disabled, 0)
  2317.       end
  2318.       else do
  2319.         call bguiset(obj.monthchoice_, winID, GA_Disabled, 1)
  2320.         if App == 'PGS' then call bguiset(obj.endmonthchoice_, winID, GA_Disabled, 1)
  2321.       end
  2322.     end
  2323.     /**/
  2324.  
  2325.     /***//*** GoGad ***/
  2326.     when id == id.go_ then do
  2327.       CalType = bguiget(obj.calendartype_, CYC_Active) + 1
  2328.       if (App == 'FW') & (CalType == 2) then CalType = 3
  2329.       EnteredYear = bguiget(obj.yearchoice_, STRINGA_TextVal)
  2330.       Month = bguiget(obj.monthchoice_, CYC_Active) + 1
  2331.       if CalType == 2 then EndMonth = bguiget(obj.endmonthchoice_, CYC_Active) + 1
  2332.       Done = 1
  2333.     end
  2334.     /**/
  2335.  
  2336.     /***//*** Extras Gads ***/
  2337.       when id == id.bottomleft_ then   call ControlMX(0, bguiget(obj.bottomleft_, MX_Active))
  2338.       when id == id.bottomcenter_ then call ControlMX(1, bguiget(obj.bottomcenter_, MX_Active))
  2339.       when id == id.bottomright_ then  call ControlMX(2, bguiget(obj.bottomright_, MX_Active))
  2340.       when id == id.topcenter_ then    call ControlMX(3, bguiget(obj.topcenter_, MX_Active))
  2341.       when id == id.topright_ then     call ControlMX(4, bguiget(obj.topright_, MX_Active))
  2342.     /**/
  2343.       otherwise nop
  2344.     end
  2345.     if (Done == 1) | (Reset > 0) then leave
  2346.   end
  2347. /**/
  2348.  
  2349.   do DSR_Posn = 0 to PosnCount
  2350.     interpret "Do"Do.DSR_Posn" = ''"
  2351.   end
  2352.   do DSR_Grp = 0 to GroupCount
  2353.     DSR_Posn = DSR_Sel.DSR_Grp
  2354.     interpret "Do"Do.DSR_Posn" = translate(DSR_Grp, 'BBBTT', '01234')||translate(DSR_Grp, 'LCRCR', '01234')"
  2355.   end
  2356.  
  2357.   if DoBothJ ~= '' then do
  2358.     DoJulian = DoBothJ
  2359.     DoJulianLeft = DoBothJ
  2360.   end
  2361.   if DoBothS ~= '' then do
  2362.     DoSunrise = DoBothS
  2363.     DoSunset = DoBothS
  2364.   end
  2365.   TopOption = sign(pos('T', DoPhases''DoWeeknumber''DoJulian''DoJulianLeft''DoSunrise''DoSunset))
  2366.  
  2367.   if CalType ~= 0 then do
  2368.     interpret CurrentFontName" = "QuoteIt(bguiget(obj.fontvalue_, STRINGA_TextVal))
  2369.     interpret CurrentColorName' = "'value('ColorList.'bguiget(obj.colorlist_, CYC_Active))'"'
  2370.  
  2371.     Value = bguiget(obj.currentvalue_, STRINGA_TextVal)
  2372.     if upper(left(CurrentMiscName, pos('.', CurrentMiscName))) == 'IMAGECLASS.' then do
  2373.       IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  2374.       interpret 'ImageFile.'IC' = Value'
  2375.     end
  2376.     else do
  2377.       if datatype(Value) == 'CHAR' then  Value = QuoteIt(Value)
  2378.       interpret CurrentMiscName' = 'Value
  2379.     end
  2380.   end
  2381.  
  2382.   return
  2383. /**/
  2384.  
  2385. /***//*** DoSetupReq_CA () ***/
  2386. DoSetupReq_CA:
  2387.   /***//*** GUI Description ***/
  2388.   UpdateVarCmds = 0
  2389.   NCColorReq = 0
  2390.   ColorReq = 0
  2391.   MonthList = '"'January$'|'February$'|'March$'|'April$'|'May$'|'June$'|'July$'|'August$'|'September$'|'October$'|'November$'|'December$'"'
  2392.   if App == 'FW' then CalendarTypeList = '"'SingleMonth$'|'WholeYear$'"'
  2393.   else CalendarTypeList = '"'SingleMonth$'|'MultiMonth$'|'WholeYear$'"'
  2394.  
  2395.   call open('CA',"awnpipe:SetupReq/xc")
  2396.   call ToPIPE('CA', '"'VarGUITitle$'" m cg dg v db si a cs sk sq h ps="'AppScreen'"')
  2397.   call ToPIPE('CA', 'layout v si so cj')
  2398.     DisplayNameGad = ToPIPE('CA', 'button ro b=0')
  2399.     call AssignID('ClickTab', ToPIPE('CA', 'clicktab ctl="'OptLayout$'|'Variables$'|'Top$'|'Bottom$'"'))
  2400.  
  2401.     /***//** Options & Layout Tab **/
  2402.     call ToPIPE('CA', 'layout v si so b=0 page='ClickTab)
  2403.       call ToPIPE('CA', 'layout b=3 gt="'Options$'"')
  2404.         call ToPIPE('CA', 'layout v si so b=0')
  2405.           call AssignID('MiniCalsGad', ToPIPE('CA', 'checkbox gt="'MiniCals$'"'))
  2406.           call AssignID('HighlightsGad', ToPIPE('CA', 'checkbox gt="'Highlights$'"'))
  2407.           call AssignID('ImagesGad', ToPIPE('CA', 'checkbox gt="'Images$'"'))
  2408.           call AssignID('BoxDatesGad', ToPIPE('CA', 'checkbox gt="'BoxDates$'"'))
  2409.         call ToPIPE('CA', 'le')
  2410.         call ToPIPE('CA', 'layout v si so b=0')
  2411.           call AssignID('ExtendedGad', ToPIPE('CA', 'checkbox gt="'Extended$'"'))
  2412.           call AssignID('TopLongGad', ToPIPE('CA', 'checkbox gt="'TopLong$'"'))
  2413.           call AssignID('NoteBoxGad', ToPIPE('CA', 'checkbox gt="'NoteBox$'"'))
  2414.           call ToPIPE('CA', 'space')
  2415.         call ToPIPE('CA', 'le')
  2416.       call ToPIPE('CA', 'le')
  2417.  
  2418.       call ToPIPE('CA', 'layout v si so cj b=3 gt="'OrientMarg$'"')
  2419.         call ToPIPE('CA', 'layout b=0')
  2420.           call ToPIPE('CA', 'space')
  2421.           call AssignID('TopMargGad', ToPIPE('CA', 'string cj tc weiw=20'))
  2422.           call ToPIPE('CA', 'space')
  2423.         call ToPIPE('CA', 'le')
  2424.         call ToPIPE('CA', 'layout si b=0')
  2425.           call ToPIPE('CA', 'space')
  2426.           call AssignID('LeftMargGad', ToPIPE('CA', 'string cj tc weiw=20'))
  2427.           call AssignID('OrientationGad', ToPIPE('CA', 'chooser pu weiw=20 cl="'Wide$'|'Tall$'"'))
  2428.           call AssignID('RightMargGad', ToPIPE('CA', 'string cj tc weiw=20'))
  2429.           call ToPIPE('CA', 'space')
  2430.         call ToPIPE('CA', 'le')
  2431.         call ToPIPE('CA', 'layout b=0')
  2432.           call ToPIPE('CA', 'space')
  2433.           call AssignID('BottomMargGad', ToPIPE('CA', 'string cj tc weiw=20'))
  2434.           call ToPIPE('CA', 'space')
  2435.         call ToPIPE('CA', 'le')
  2436.       call ToPIPE('CA', 'le')
  2437.     call ToPIPE('CA', 'le')
  2438.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  2439.     /**/
  2440.  
  2441.     /***//** Variables Tab **/
  2442.     call ToPIPE('CA', 'layout v si so b=0 page='ClickTab)
  2443.       call ToPIPE('CA', 'layout so b=3 gt="'Fonts$'"')
  2444.         call AssignID('FontVarGad', ToPIPE('CA', 'chooser pu maxn=50 weiw=45'))
  2445.         call AssignID('FontValGad', ToPIPE('CA', 'string lj tc weiw=50'))
  2446.         call AssignID('ChooseFontGad', ToPIPE('CA', 'button ab=2 weiw=0 weih=0'))
  2447.       call ToPIPE('CA', 'le')
  2448.  
  2449.       call ToPIPE('CA', 'layout v b=3 gt="'Colors$'" si so')
  2450.         call ToPIPE('CA', 'layout b=0')
  2451.           call AssignID('ColorVarGad', ToPIPE('CA', 'button weiw=50 weih=0'))
  2452.           call AssignID('CycleColorVarGad', ToPIPE('CA', 'button weiw=0 gt=">"'))
  2453.           call AssignID('ColorValGad', ToPIPE('CA', 'button weiw=45 weih=0'))
  2454.         call ToPIPE('CA', 'le')
  2455.         call AssignID('MatchColorsGad', ToPIPE('CA', 'checkbox gt="'MatchColors$'"'))
  2456.         call AssignID('DailyColorsGad', ToPIPE('CA', 'checkbox gt="'DailyColors$'"'))
  2457.       call ToPIPE('CA', 'le')
  2458.  
  2459.       call ToPIPE('CA', 'layout v b=3 gt="'MiscVar$'" si so')
  2460.         call ToPIPE('CA', 'layout b=0')
  2461.           call ToPIPE('CA', 'space')
  2462.           call AssignID('HighlightEditGad', ToPIPE('CA', 'button gt="'HighlightEd$'"'))
  2463.           call ToPIPE('CA', 'space')
  2464.         call ToPIPE('CA', 'le')
  2465.         call ToPIPE('CA', 'layout b=0')
  2466.           call AssignID('MiscVarGad', ToPIPE('CA', 'button weiw=50'))
  2467.           call AssignID('CycleMiscVarGad', ToPIPE('CA', 'button weiw=0 gt=">"'))
  2468.           call AssignID('MiscValGad', ToPIPE('CA', 'string lj tc weiw=40 weih=0'))
  2469.           call AssignID('ChooseValGad', ToPIPE('CA', 'button ab=0 weiw=0 weih=0'))
  2470.           call AssignID('AddImageClassGad', ToPIPE('CA', 'button weiw=0 gt="'AddIC$'"'))
  2471.         call ToPIPE('CA', 'le')
  2472.       call ToPIPE('CA', 'le')
  2473.     call ToPIPE('CA', 'le')
  2474.  
  2475.     GadText.CycleColorVarGad.0 = '>'
  2476.     GadText.CycleColorVarGad.1 = '<'
  2477.     GadText.CycleMiscVarGad.0 = '>'
  2478.     GadText.CycleMiscVarGad.1 = '<'
  2479.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  2480.     /**/
  2481.  
  2482.     /***//** Top Options Tab **/
  2483.     call ToPIPE('CA', 'layout b=0 page='ClickTab)
  2484.       call ToPIPE('CA', 'space')
  2485.  
  2486.       call ToPIPE('CA', 'layout v cj b=3')
  2487.         call ToPIPE('CA', 'label gt="'Top$'*n'Center$'"')
  2488.         call ToPIPE('CA', 'layout v so b=0')
  2489.           call AssignID('Gad.3.0', ToPIPE('CA', 'checkbox gt="'None$'"'))
  2490.           call AssignID('Gad.3.1', ToPIPE('CA', 'checkbox gt="'Phases$'"'))
  2491.           call AssignID('Gad.3.2', ToPIPE('CA', 'checkbox gt="'Weeknumber$'"'))
  2492.           call AssignID('Gad.3.3', ToPIPE('CA', 'checkbox gt="'Julian$'"'))
  2493.           call AssignID('Gad.3.4', ToPIPE('CA', 'checkbox gt="'JulLeft$'"'))
  2494.           call AssignID('Gad.3.5', ToPIPE('CA', 'checkbox gt="'JulJulLeft$'"'))
  2495.           call AssignID('Gad.3.6', ToPIPE('CA', 'checkbox gt="'Sunrise$'"'))
  2496.           call AssignID('Gad.3.7', ToPIPE('CA', 'checkbox gt="'Sunset$'"'))
  2497.           call AssignID('Gad.3.8', ToPIPE('CA', 'checkbox gt="'RiseSet$'"'))
  2498.           call ToPIPE('CA', 'space')
  2499.         call ToPIPE('CA', 'le')
  2500.       call ToPIPE('CA', 'le')
  2501.  
  2502.       call ToPIPE('CA', 'layout v cj b=3')
  2503.         call ToPIPE('CA', 'label gt="'Top$'*n'Right$'"')
  2504.         call ToPIPE('CA', 'layout v so b=0')
  2505.           call AssignID('Gad.4.0', ToPIPE('CA', 'checkbox gt="'None$'"'))
  2506.           call AssignID('Gad.4.1', ToPIPE('CA', 'checkbox gt="'Phases$'"'))
  2507.           call AssignID('Gad.4.2', ToPIPE('CA', 'checkbox gt="'Weeknumber$'"'))
  2508.           call AssignID('Gad.4.3', ToPIPE('CA', 'checkbox gt="'Julian$'"'))
  2509.           call AssignID('Gad.4.4', ToPIPE('CA', 'checkbox gt="'JulLeft$'"'))
  2510.           call AssignID('Gad.4.5', ToPIPE('CA', 'checkbox gt="'JulJulLeft$'"'))
  2511.           call AssignID('Gad.4.6', ToPIPE('CA', 'checkbox gt="'Sunrise$'"'))
  2512.           call AssignID('Gad.4.7', ToPIPE('CA', 'checkbox gt="'Sunset$'"'))
  2513.           call AssignID('Gad.4.8', ToPIPE('CA', 'checkbox gt="'RiseSet$'"'))
  2514.           call ToPIPE('CA', 'space')
  2515.         call ToPIPE('CA', 'le')
  2516.       call ToPIPE('CA', 'le')
  2517.     call ToPIPE('CA', 'le')
  2518.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  2519.     /**/
  2520.  
  2521.     /***//** Bottom Options Tab **/
  2522.     call ToPIPE('CA', 'layout b=0 page='ClickTab)
  2523.       call ToPIPE('CA', 'layout v cj b=3')
  2524.         call ToPIPE('CA', 'label gt="'Bottom$'*n'Left$'"')
  2525.         call ToPIPE('CA', 'layout v so b=0')
  2526.           call AssignID('Gad.0.0', ToPIPE('CA', 'checkbox gt="'None$'"'))
  2527.           call AssignID('Gad.0.1', ToPIPE('CA', 'checkbox gt="'Phases$'"'))
  2528.           call AssignID('Gad.0.2', ToPIPE('CA', 'checkbox gt="'Weeknumber$'"'))
  2529.           call AssignID('Gad.0.3', ToPIPE('CA', 'checkbox gt="'Julian$'"'))
  2530.           call AssignID('Gad.0.4', ToPIPE('CA', 'checkbox gt="'JulLeft$'"'))
  2531.           call AssignID('Gad.0.5', ToPIPE('CA', 'checkbox gt="'JulJulLeft$'"'))
  2532.           call AssignID('Gad.0.6', ToPIPE('CA', 'checkbox gt="'Sunrise$'"'))
  2533.           call AssignID('Gad.0.7', ToPIPE('CA', 'checkbox gt="'Sunset$'"'))
  2534.           call AssignID('Gad.0.8', ToPIPE('CA', 'checkbox gt="'RiseSet$'"'))
  2535.           call ToPIPE('CA', 'space')
  2536.         call ToPIPE('CA', 'le')
  2537.       call ToPIPE('CA', 'le')
  2538.  
  2539.       call ToPIPE('CA', 'layout v cj b=3')
  2540.         call ToPIPE('CA', 'label gt="'Bottom$'*n'Center$'"')
  2541.         call ToPIPE('CA', 'layout v so b=0')
  2542.           call AssignID('Gad.1.0', ToPIPE('CA', 'checkbox gt="'None$'"'))
  2543.           call AssignID('Gad.1.1', ToPIPE('CA', 'checkbox gt="'Phases$'"'))
  2544.           call AssignID('Gad.1.2', ToPIPE('CA', 'checkbox gt="'Weeknumber$'"'))
  2545.           call AssignID('Gad.1.3', ToPIPE('CA', 'checkbox gt="'Julian$'"'))
  2546.           call AssignID('Gad.1.4', ToPIPE('CA', 'checkbox gt="'JulLeft$'"'))
  2547.           call AssignID('Gad.1.5', ToPIPE('CA', 'checkbox gt="'JulJulLeft$'"'))
  2548.           call AssignID('Gad.1.6', ToPIPE('CA', 'checkbox gt="'Sunrise$'"'))
  2549.           call AssignID('Gad.1.7', ToPIPE('CA', 'checkbox gt="'Sunset$'"'))
  2550.           call AssignID('Gad.1.8', ToPIPE('CA', 'checkbox gt="'RiseSet$'"'))
  2551.           call AssignID('Gad.1.9', ToPIPE('CA', 'checkbox gt="'History$'"'))
  2552.           call AssignID('Gad.1.10', ToPIPE('CA', 'checkbox gt="'Random$'"'))
  2553.           call ToPIPE('CA', 'space')
  2554.         call ToPIPE('CA', 'le')
  2555.       call ToPIPE('CA', 'le')
  2556.  
  2557.       call ToPIPE('CA', 'layout v cj b=3')
  2558.         call ToPIPE('CA', 'label gt="'Bottom$'*n'Right$'"')
  2559.         call ToPIPE('CA', 'layout v so b=0')
  2560.           call AssignID('Gad.2.0', ToPIPE('CA', 'checkbox gt="'None$'"'))
  2561.           call AssignID('Gad.2.1', ToPIPE('CA', 'checkbox gt="'Phases$'"'))
  2562.           call AssignID('Gad.2.2', ToPIPE('CA', 'checkbox gt="'Weeknumber$'"'))
  2563.           call AssignID('Gad.2.3', ToPIPE('CA', 'checkbox gt="'Julian$'"'))
  2564.           call AssignID('Gad.2.4', ToPIPE('CA', 'checkbox gt="'JulLeft$'"'))
  2565.           call AssignID('Gad.2.5', ToPIPE('CA', 'checkbox gt="'JulJulLeft$'"'))
  2566.           call AssignID('Gad.2.6', ToPIPE('CA', 'checkbox gt="'Sunrise$'"'))
  2567.           call AssignID('Gad.2.7', ToPIPE('CA', 'checkbox gt="'Sunset$'"'))
  2568.           call AssignID('Gad.2.8', ToPIPE('CA', 'checkbox gt="'RiseSet$'"'))
  2569.           call ToPIPE('CA', 'space')
  2570.         call ToPIPE('CA', 'le')
  2571.       call ToPIPE('CA', 'le')
  2572.     call ToPIPE('CA', 'le')
  2573.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  2574.     /**/
  2575.  
  2576.     /***//** Control Buttons **/
  2577.     call ToPIPE('CA', 'layout si so b=0')
  2578.       call ToPIPE('CA', 'space')
  2579.       call AssignID('SwitchGad1', ToPIPE('CA', 'chooser pu cl='MonthList))
  2580.       call AssignID('SwitchGad2', ToPIPE('CA', 'integer a tc weiw=5 maxc=4'))
  2581.       call AssignID('SwitchGad3', ToPIPE('CA', 'button b=0 weiw=30 weih=0 gt=""'))
  2582.       call ToPIPE('CA', 'space')
  2583.     call ToPIPE('CA', 'le')
  2584.  
  2585.     call ToPIPE('CA', 'layout cj si so b=0')
  2586.       call AssignID('CalendarTypeGad', ToPIPE('CA', 'chooser pu weiw=0 weih=0 cl='CalendarTypeList))
  2587.       call AssignID('GoGad', ToPIPE('CA', 'button weih=0 gt="'Go$'"'))
  2588.       call ToPIPE('CA', 'space')
  2589.       call AssignID('ResetGad', ToPIPE('CA', 'button weih=0 gt="'Reset$'"'))
  2590.       call AssignID('LoadGad', ToPIPE('CA', 'button weih=0 gt="'Load$'"'))
  2591.       call AssignID('SaveAsGad', ToPIPE('CA', 'button weih=0 gt="'SaveAs$'"'))
  2592.       call ToPIPE('CA', 'space')
  2593.       call AssignID('CancelGad', ToPIPE('CA', 'button weih=0 gt="'Cancel$'" c'))
  2594.     call ToPIPE('CA', 'le')
  2595.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  2596.     /**/
  2597.  
  2598.     /***//*** Other Objects ***/
  2599.     GetFileAllGad = ToPIPE('CA', 'getfile ua pat="#?"')
  2600.     GetFileDataGad = ToPIPE('CA', 'getfile ua pat="#?.(data|prefs)"')
  2601.  
  2602.     if App == 'PGS' then do
  2603.       call open('FontReq', "awnpipe:FontReq/xc")
  2604.       call ToPIPE('FontReq', '"'SelectFont$'" m db dg v db a ps="'AppScreen'"')
  2605.       call ToPIPE('FontReq', 'listbrowser minw=200 minh=300')
  2606.       do DSR_FontNumber = 0 to FontList.COUNT - 1
  2607.         GadID = ToPIPE('FontReq', 'browsernode gt="'FontList.DSR_FontNumber'"')
  2608.         interpret 'FontGad.'GadID' = 'DSR_FontNumber
  2609.       end
  2610.     end
  2611.  
  2612.     call open('ColorReq','awnpipe:ColorReq/xc')
  2613.     call ToPIPE('ColorReq','"Select color:" m db dg v a ps="'AppScreen'"')
  2614.     call ToPIPE('ColorReq','listbrowser minw 150 minh 75 lbl "Color|Sample"')
  2615.  
  2616.     call open('NCColorReq','awnpipe:NCColorReq/xc')
  2617.     call ToPIPE('NCColorReq','"Select color:" m db dg v a ps="'AppScreen'"')
  2618.     call ToPIPE('NCColorReq','listbrowser minw 150 minh 75 lbl "Color|Sample"')
  2619.     if App == 'FW' then do
  2620.       do GE_ColorNumber = 0 to ColorList.Count - 2
  2621.         if UpdateBusy(Req, 1) == -1 then call Cleanup
  2622.         RPen = dTox(x2d(left(ColorRegister.GE_ColorNumber, 2)) / 255 * 4294967295)
  2623.         GPen = dTox(x2d(substr(ColorRegister.GE_ColorNumber, 3, 2)) / 255 * 4294967295)
  2624.         BPen = dTox(x2d(right(ColorRegister.GE_ColorNumber, 2)) / 255 * 4294967295)
  2625.  
  2626.         call ToPIPE('ColorReq','penmap pmp 1|'RPen'|'GPen'|'BPen' pmd 0|'d2x(ColorW)'|0|'d2x(ColorH)''copies('|0', ColorW * ColorH))
  2627. /* call AddMsg('I', 'Color 'GE_ColorNumber' = >'Colorlist.GE_ColorNumber'<') */
  2628.         GadID = ToPIPE('ColorReq','browsernode gt="'ColorList.GE_ColorNumber'|¶"')
  2629.         interpret 'ColorGad.'GadID' = 'GE_ColorNumber
  2630.  
  2631.         call ToPIPE('NCColorReq','penmap pmp 1|'RPen'|'GPen'|'BPen' pmd 0|'d2x(ColorW)'|0|'d2x(ColorH)''copies('|0', ColorW * ColorH))
  2632.         GadID = ToPIPE('NCColorReq','browsernode gt="'ColorList.GE_ColorNumber'|¶"')
  2633.         interpret 'NCColorGad.'GadID' = 'GE_ColorNumber
  2634.       end
  2635.       GadID = ToPIPE('ColorReq','browsernode gt="<'Clear$'>|¶"')
  2636.       interpret 'ColorGad.'GadID' = 'GE_ColorNumber
  2637.     end
  2638.     else if App == 'PGS' then do
  2639.       do GE_ColorNumber = 0 to ColorList.Count - 2
  2640.         if UpdateBusy(Req, 1) == -1 then call Cleanup
  2641.         GadID = ToPIPE('ColorReq','browsernode gt="'ColorList.GE_ColorNumber'|"')
  2642.         interpret 'ColorGad.'GadID' = 'GE_ColorNumber
  2643.         GadID = ToPIPE('NCColorReq','browsernode gt="'ColorList.GE_ColorNumber'|"')
  2644.         interpret 'NCColorGad.'GadID' = 'GE_ColorNumber
  2645.       end
  2646.       GadID = ToPIPE('ColorReq','browsernode gt="<'Clear$'>|"')
  2647.       interpret 'ColorGad.'GadID' = 'GE_ColorNumber
  2648.     end
  2649.     /**/
  2650.  
  2651.   call ToPIPE('CA', 'le')
  2652.   call ToPIPE('CA', "open")
  2653.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  2654. /**/
  2655.  
  2656.   /***//*** GUI Action Loop ***/
  2657.   call CA_UpdateGads
  2658.   Done = 0
  2659.   do until Done == 1
  2660.     call ToPIPE('CA', 'continue')
  2661.     DSR_EventInfo = readln('CA')
  2662.     parse var DSR_EventInfo DSR_Event' 'DSR_GadID' 'DSR_GadInfo1
  2663.     select
  2664.       when DSR_Event == 'close' then call Cleanup
  2665.  
  2666.     /***//*** Help event ***/
  2667.       when DSR_Event == 'help' then do
  2668.         if DSR_GadID ~= -1 then do
  2669.           OverGad = DSR_GadID
  2670.           if (DSR_GadID ~= ShiftedGad) & (ShiftedGad > 0) then do
  2671.             call ToPIPE('CA', 'id 'ShiftedGad' gt="'GadText.ShiftedGad.0'"')
  2672.             ShiftedGad = 0
  2673.           end
  2674.           if (ShiftDown == 1) & (symbol('GadText.OverGad.1') == 'VAR') then do
  2675.             call ToPIPE('CA', 'id 'OverGad' gt="'GadText.OverGad.1'"')
  2676.             ShiftedGad = OverGad
  2677.           end
  2678.         end
  2679.       end
  2680.     /**/
  2681.  
  2682.     /***//*** Qualifier event ***/
  2683.       when DSR_Event == 'qual' then do
  2684.         ShiftDown = (DSR_GadID == 1)|(DSR_GadID == 2)
  2685.         if (ShiftDown == 0) & (ShiftedGad > 0) then do
  2686.           call ToPIPE('CA', 'id 'ShiftedGad' gt="'GadText.OverGad.0'"')
  2687.           ShiftedGad = 0
  2688.         end
  2689.         if (ShiftDown == 1) & (symbol('GadText.OverGad.1') == 'VAR') then do
  2690.           call ToPIPE('CA', 'id 'OverGad' gt="'GadText.OverGad.1'"')
  2691.           ShiftedGad = OverGad
  2692.         end
  2693.       end
  2694.     /**/
  2695.  
  2696.     /***//*** Key event ***/
  2697.       when DSR_Event == 'key' then do
  2698.         HelpGad = DSR_Help.OverGad
  2699.         interpret 'HelpText = Help$.'HelpGad
  2700.         if (DSR_GadID == 95) & (symbol('Help$.'HelpGad) == 'VAR') & (HelpText ~= '') then
  2701.           call CASimpleReq(Help$, HelpText, HelpTime)
  2702.       end
  2703.     /**/
  2704.  
  2705.     /***//*** CalendarTypeGad ***/
  2706.       when DSR_GadID == CalendarTypeGad then do
  2707.         call ReadMonthYearGads
  2708.         CalType = DSR_GadInfo1 + 1
  2709.         if (App == 'FW') & (CalType == 2) then CalType = 3
  2710.         if CalType == 1 then do
  2711.           call AssignID('SwitchGad1', ToPIPE('CA', 'define chooser replace='SwitchGad1' pu cl='MonthList' s='Month - 1))
  2712.           call AssignID('SwitchGad2', ToPIPE('CA', 'define integer replace='SwitchGad2' a tc weiw=5 maxc=4 defn='EnteredYear))
  2713.           call AssignID('SwitchGad3', ToPIPE('CA', 'define button replace='SwitchGad3' b=0 gt=""'))
  2714.           call ToPIPE('CA', 'refresh')
  2715.           Help$.SwitchGad1Help = Help$.MonthGadHelp
  2716.           Help$.SwitchGad2Help = Help$.YearGadHelp
  2717.           Help$.SwitchGad3Help = ''
  2718.         end
  2719.         else if CalType == 2 then do
  2720.           call AssignID('SwitchGad1', ToPIPE('CA', 'define chooser replace='SwitchGad1' pu cl='MonthList' s='Month - 1))
  2721.           call AssignID('SwitchGad2', ToPIPE('CA', 'define chooser replace='SwitchGad2' pu cl='MonthList' s='EndMonth - 1))
  2722.           call AssignID('SwitchGad3', ToPIPE('CA', 'define integer replace='SwitchGad3' a tc weiw=5 maxc=4 defn='EnteredYear))
  2723.           call ToPIPE('CA', 'refresh')
  2724.           Help$.SwitchGad1Help = Help$.StartMonthGadHelp
  2725.           Help$.SwitchGad2Help = Help$.EndMonthGadHelp
  2726.           Help$.SwitchGad3Help = Help$.YearGadHelp
  2727.         end
  2728.         else do
  2729.           call AssignID('SwitchGad1', ToPIPE('CA', 'define button replace='SwitchGad1' b=0 gt=""'))
  2730.           call AssignID('SwitchGad2', ToPIPE('CA', 'define integer replace='SwitchGad2' a tc weiw=5 maxc=4 defn='EnteredYear))
  2731.           call AssignID('SwitchGad3', ToPIPE('CA', 'define button replace='SwitchGad3' b=0 gt=""'))
  2732.           call ToPIPE('CA', 'refresh')
  2733.           Help$.SwitchGad1Help = ''
  2734.           Help$.SwitchGad2Help = Help$.YearGadHelp
  2735.           Help$.SwitchGad3Help = ''
  2736.         end
  2737.       end
  2738.     /**/
  2739.  
  2740.     /***//*** GoGad ***/
  2741.       when DSR_GadID == GoGad then do
  2742.         CalType = ReadCAGad('CA', CalendarTypeGad) + 1
  2743.         if (App == 'FW') & (CalType == 2) then CalType = 3
  2744.         call ReadMonthYearGads
  2745.         call CA_InterpretMX
  2746.         Done = 1
  2747.       end
  2748.     /**/
  2749.  
  2750.     /***//*** ResetGad ***/
  2751.       when DSR_GadID == ResetGad then do
  2752.         PrefsFile = 'Default'
  2753.         call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  2754.         call CA_UpdateGads
  2755.       end
  2756.     /**/
  2757.  
  2758.     /***//*** LoadGad ***/
  2759.       when DSR_GadID == LoadGad then do
  2760.         if PrefsFile ~= 'Default' then do
  2761.           DefaultSource = PathPart(PrefsFile)
  2762.           DefaultFile = FilePart(PrefsFile)
  2763.         end
  2764.         else do
  2765.           DefaultSource = ScriptDir
  2766.           DefaultFile = 'FWCalendar.prefs'
  2767.         end
  2768.         DSR_File = CAGetFile('CA', GetFileDataGad, SelectFile$, DefaultSource''DefaultFile)
  2769.         if (DSR_File ~= '') & (exists(DSR_File)) then do
  2770.           PrefsFile = DSR_File
  2771.           call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  2772.           GSI_Data = ReadFile(PrefsFile)
  2773.           GSI_UpperData = upper(GSI_Data)
  2774.           call CA_UpdateGads
  2775.         end
  2776.         else do
  2777.           call ToPIPE('CA', 'id 0 s=256')
  2778.           call CASimpleReq('FWCalendar 'Notice$, PrefsFile' 'CantFind$'...')
  2779.           call ToPIPE('CA', 'id 0 s=512')
  2780.         end
  2781.       end
  2782.     /**/
  2783.  
  2784.     /***//*** SaveAsGad ***/
  2785.       when DSR_GadID == SaveAsGad then do
  2786.         if PrefsFile ~= 'Default' then do
  2787.           DefaultSource = PathPart(PrefsFile)
  2788.           DefaultFile = FilePart(PrefsFile)
  2789.         end
  2790.         else do
  2791.           DefaultSource = ScriptDir
  2792.           DefaultFile = 'FWCalendar.prefs'
  2793.         end
  2794.         DSR_File = CAGetFile('CA', GetFileDataGad, SelectPrefs$, DefaultSource''DefaultFile)
  2795.         if DSR_File ~= '' then do
  2796.           PrefsFile = DSR_File
  2797.           call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  2798.         end
  2799.       end
  2800.     /**/
  2801.  
  2802.     /***//*** ExtendedGad ***/
  2803.       when DSR_GadID == ExtendedGad then do
  2804.         DoExtended = DSR_GadInfo1
  2805.         if DoExtended == 1 then do
  2806.           call ToPIPE('CA', 'id 'TopLongGad' s=0 dis=1 page='ClickTab' refresh')
  2807.           call ToPIPE('CA', 'id 'NoteBoxGad' s=0 dis=1 page='ClickTab' refresh')
  2808.           DoTopExtraWk = 0
  2809.           DoNoteBox = 0
  2810.         end
  2811.         else do
  2812.           call ToPIPE('CA', 'id 'TopLongGad' dis=0 page='ClickTab' refresh')
  2813.           call ToPIPE('CA', 'id 'NoteBoxGad' dis=0 page='ClickTab' refresh')
  2814.         end
  2815.       end
  2816.     /**/
  2817.  
  2818.     /***//*** OrientationGad ***/
  2819.       when DSR_GadID == OrientationGad then  do
  2820.         if DSR_GadInfo1 == 0 then Orientation = 'Wide'
  2821.         else Orientation = 'Tall'
  2822.       end
  2823.     /**/
  2824.  
  2825.     /***//*** Checkbox Gads ***/
  2826.       when DSR_GadID == MinicalsGad then     DoMiniCals = DSR_GadInfo1
  2827.       when DSR_GadID == HighlightsGad then   DoHighlights = DSR_GadInfo1
  2828.       when DSR_GadID == TopLongGad then      DoTopExtraWk = DSR_GadInfo1
  2829.       when DSR_GadID == NoteBoxGad then      DoNoteBox = DSR_GadInfo1
  2830.       when DSR_GadID == BoxDatesGad then     DoDateBox = DSR_GadInfo1
  2831.       when DSR_GadID == ImagesGad then       DoImages = DSR_GadInfo1
  2832.       when DSR_GadID == MatchColorsGad then  DoMatchColors = DSR_GadInfo1
  2833.       when DSR_GadID == DailyColorsGad then  DoDailyColors = DSR_GadInfo1
  2834.     /**/
  2835.  
  2836.     /***//*** FontValGad ***/
  2837.       when DSR_GadID == FontValGad then do
  2838.         if DSR_GadInfo1 ~= value(CurrentFontName) then do
  2839.           call ToPIPE('CA', 'id 0 s=256')
  2840.           call CASimpleReq('FWCalendar 'Notice$, MustUse$)
  2841.           call ToPIPE('CA', 'id 0 s=512')
  2842.           call ToPIPE('CA', 'id 'FontValGad' gt="'value(CurrentFontName)'" page='ClickTab' refresh')
  2843.         end
  2844.       end
  2845.     /**/
  2846.  
  2847.     /***//*** ChooseFontGad ***/
  2848.       when DSR_GadID == ChooseFontGad then do
  2849.         if App == 'FW' then do
  2850.           DSR_File = CAGetFile('CA', GetFileAllGad, SelectFont$, CurrentDir'FWFonts/SWOLFonts/')
  2851.           if DSR_File ~= '' then do
  2852.             interpret CurrentFontName" = "QuoteIt(DSR_File)
  2853.             call ToPIPE('CA', 'id 'FontValGad' gt="'value(CurrentFontName)'" page='ClickTab' refresh')
  2854.           end
  2855.         end
  2856.         else if App == 'PGS' then do
  2857.           call ToPIPE('CA', 'id 0 s=256')
  2858.           interpret CurrentFontName" = "QuoteIt(ReadBrowserList('FontReq', 'FontGad', 'FontList', value(CurrentFontName)))
  2859.           call ToPIPE('CA', 'id 'FontValGad' gt="'value(CurrentFontName)'" page='ClickTab' refresh')
  2860.           call ToPIPE('CA', 'id 0 s=512')
  2861.         end
  2862.       end
  2863.     /**/
  2864.  
  2865.     /***//*** FontVarGad ***/
  2866.       when DSR_GadID == FontVarGad then do
  2867.         CurrentFontName = FontVarName.DSR_GadInfo1
  2868.         call ToPIPE('CA', 'id 'FontValGad' gt="'value(CurrentFontName)'" page='ClickTab' refresh')
  2869.       end
  2870.     /**/
  2871.  
  2872.     /***//*** ColorVarGad ***/
  2873.       when DSR_GadID == ColorVarGad then do
  2874.         call ToPIPE('CA', 'id 0 s=256')
  2875.         CurrentColorName = ReadBrowserList('ColorVarReq', 'ColorVarGad', 'ColorVarName', CurrentColorName)
  2876.         call ToPIPE('CA', 'id 'ColorVarGad' gt="'CurrentColorName'" page='ClickTab)
  2877.         call ToPIPE('CA', 'id 'ColorValGad' gt="'value(CurrentColorName)'" page='ClickTab)
  2878.         call ToPIPE('CA', 'id 0 s=512')
  2879.       end
  2880.     /**/
  2881.  
  2882.     /***//*** CycleColorVarGad ***/
  2883.       when DSR_GadID == CycleColorVarGad then do
  2884.         CurrentColorNum = MemberID(CurrentColorName, 'ColorVarName')
  2885.         if ShiftDown == 1 then do
  2886.           CurrentColorNum = CurrentColorNum - 1
  2887.           if CurrentColorNum < 0 then CurrentColorNum = ColorVarName.Count - 1
  2888.         end
  2889.         else do
  2890.           CurrentColorNum = CurrentColorNum + 1
  2891.           if CurrentColorNum = ColorVarName.Count then CurrentColorNum = 0
  2892.         end
  2893.         CurrentColorName = ColorVarName.CurrentColorNum
  2894.         call ToPIPE('CA', 'id 'ColorVarGad' gt="'CurrentColorName'" page='ClickTab)
  2895.         call ToPIPE('CA', 'id 'ColorValGad' gt="'value(CurrentColorName)'" page='ClickTab)
  2896.       end
  2897.     /**/
  2898.  
  2899.     /***//*** ColorValGad ***/
  2900.       when DSR_GadID == ColorValGad then do
  2901.         call ToPIPE('CA', 'id 0 s=256')
  2902.         if pos('BACKGROUND.', upper(CurrentColorName)) == 0 then CurrentColor = ReadBrowserList('NCColorReq', 'NCColorGad', 'NCColorList')
  2903.         else CurrentColor = ReadBrowserList('ColorReq', 'ColorGad', 'ColorList')
  2904.         interpret CurrentColorName' = "'CurrentColor'"'
  2905.         call ToPIPE('CA', 'id 'ColorValGad' gt="'CurrentColor'" page='ClickTab)
  2906.         call ToPIPE('CA', 'id 0 s=512')
  2907.       end
  2908.     /**/
  2909.  
  2910.     /***//*** MiscVarGad ***/
  2911.       when DSR_GadID == MiscVarGad then do
  2912.         call ProcessMiscValGad(ReadCAGad('CA', MiscValGad))
  2913.         call ToPIPE('CA', 'id 0 s=256')
  2914.         CurrentMiscName = ReadBrowserList('MiscVarReq', 'MiscVarGad', 'MiscVarName', CurrentMiscName)
  2915.         call UpdateMiscVarGad
  2916.         call ToPIPE('CA', 'id 0 s=512')
  2917.       end
  2918.     /**/
  2919.  
  2920.     /***//*** CycleMiscVarGad ***/
  2921.       when DSR_GadID == CycleMiscVarGad then do
  2922.         call ProcessMiscValGad(ReadCAGad('CA', MiscValGad))
  2923.         CurrentMiscNum = MemberID(CurrentMiscName, 'MiscVarName')
  2924.         if ShiftDown == 1 then do
  2925.           CurrentMiscNum = CurrentMiscNum - 1
  2926.           if CurrentMiscNum < 0 then CurrentMiscNum = MiscVarName.Count - 1
  2927.         end
  2928.         else do
  2929.           CurrentMiscNum = CurrentMiscNum + 1
  2930.           if CurrentMiscNum = MiscVarName.Count then CurrentMiscNum = 0
  2931.         end
  2932.         CurrentMiscName = MiscVarName.CurrentMiscNum
  2933.         call UpdateMiscVarGad
  2934.       end
  2935.     /**/
  2936.  
  2937.     /***//*** MiscValGad ***/
  2938.       when DSR_GadID == MiscValGad then do
  2939.         if VarReqGad == 0 then do
  2940.           if left(upper(CurrentMiscName), 11) == 'IMAGECLASS.' then do
  2941.             if DSR_GadInfo1 ~= '' then do
  2942.               call ToPIPE('CA', 'id 0 s=256')
  2943.               call CASimpleReq('FWCalendar 'Notice$, MustUse$)
  2944.               call ToPIPE('CA', 'id 0 s=512')
  2945.               IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  2946.               call ToPIPE('CA', 'id 'MiscValGad' gt="'ImageFile.IC'" page='ClickTab' refresh')
  2947.             end
  2948.             else do
  2949.               IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  2950.               call ToPIPE('CA', 'id 'MiscValGad' gt="" page='ClickTab' ref')
  2951.               interpret "ImageFile."IC" = DSR_GadInfo1"
  2952.             end
  2953.           end
  2954.           else do
  2955.             call ToPIPE('CA', 'id 0 s=256')
  2956.             call CASimpleReq('FWCalendar 'Notice$, MustUse$)
  2957.             call ToPIPE('CA', 'id 0 s=512')
  2958.             call ToPIPE('CA', 'id 'MiscValGad' gt="'value(CurrentMiscName)'" page='ClickTab' refresh')
  2959.           end
  2960.         end
  2961.         else call ProcessMiscValGad(DSR_GadInfo1)
  2962.       end
  2963.     /**/
  2964.  
  2965.     /***//*** ChooseValGad ***/
  2966.       when DSR_GadID == ChooseValGad then do
  2967.  
  2968.         if (upper(CurrentMiscName) == 'GFXAPPPATH') | (upper(CurrentMiscName) == 'GFXAPP') then do
  2969.           DSR_File = CAGetFile('CA', GetFileAllGad, SelectApp$, CheckDir(GfxAppPath))
  2970.           if DSR_File ~= '' then do
  2971.             PathPart = pathpart(DSR_File)
  2972.             FilePart = filepart(DSR_File)
  2973.             if upper(CurrentMiscName) == 'GFXAPPPATH' then call ToPIPE('CA', 'id 'MiscValGad' gt="'PathPart'" page='ClickTab' refresh')
  2974.             else call ToPIPE('CA', 'id 'MiscValGad' gt="'FilePart'" page='ClickTab' ref')
  2975.             interpret 'GfxAppPath = 'QuoteIt(PathPart)
  2976.             interpret 'GfxApp = 'QuoteIt(FilePart)
  2977.             if (exists(GfxAppPath''GfxApp)) & (~exists(Storage''GfxApp)) then address command 'copy 'GfxAppPath''GfxApp' 'Storage
  2978.             if exists(Storage''GfxApp) then call ToPIPE('CA', 'id 'ImagesGad' dis=0 page='ClickTab' refresh')
  2979.           end
  2980.         end
  2981.  
  2982.         else if pos('IMAGECLASS.', upper(CurrentMiscName)) > 0 then do
  2983.           IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  2984.           DSR_File = CAGetFile('CA', GetFileAllGad, SelectImage$, CheckDir(PathPart(ImageFile.IC)))
  2985.           if DSR_File ~= '' then do
  2986.             call ToPIPE('CA', 'id 'MiscValGad' gt="'DSR_File'" page='ClickTab' ref')
  2987.             interpret "ImageFile."IC" = DSR_File"
  2988.           end
  2989.         end
  2990.  
  2991.         else do
  2992.           if upper(CurrentMiscName) == 'SUNCALCPATH' then do
  2993.             DSR_File = CAGetFile('CA', GetFileAllGad, SelectApp$, CheckDir(SunCalcPath))
  2994.             if DSR_File ~= '' then do
  2995.               PathPart = pathpart(DSR_File)
  2996.               call ToPIPE('CA', 'id 'MiscValGad' gt="'PathPart'" page='ClickTab' ref')
  2997.               interpret 'SuncalcPath = 'QuoteIt(PathPart)
  2998.               if (exists(SuncalcPath'suncalc') == 1) & (exists(Storage'Suncalc') == 0) then address command 'copy 'SunCalcPath'suncalc 'Storage
  2999.               if exists(Storage'SunCalc') == 1 then do
  3000.                 do DSR_Grp = 0 to GroupCount
  3001.                   call ToPIPE('CA', 'id 'Gad.DSR_Grp.6' dis=0 page='ClickTab' ref')
  3002.                   call ToPIPE('CA', 'id 'Gad.DSR_Grp.7' dis=0 page='ClickTab' ref')
  3003.                   call ToPIPE('CA', 'id 'Gad.DSR_Grp.8' dis=0 page='ClickTab' ref')
  3004.                 end
  3005.               end
  3006.             end
  3007.           end
  3008.         end
  3009.       end
  3010.     /**/
  3011.  
  3012.     /***//*** HighlightEditGad ***/
  3013.       when DSR_GadID == HighlightEditGad then do
  3014.         EH_SelectMonth = Month
  3015.         call ToPIPE('CA', 'id 0 s=256')
  3016.         call EditHighlight_CA
  3017.         call ToPIPE('CA', 'id 0 s=512')
  3018.       end
  3019.     /**/
  3020.  
  3021.     /***//*** AddImageClassGad ***/
  3022.       when DSR_GadID == AddImageClassGad then do
  3023.         call ToPIPE('CA', 'id 0 s=256')
  3024.         call open('Req', "awnpipe:SimpleReq/xc")
  3025.         call ToPIPE('Req', '"'EnterNewIC$'" m v db dg si so a ps="'AppScreen'"')
  3026.         Req_StringGad = ToPIPE('Req', 'string cj minw=200 gt=""')
  3027.         call ToPIPE('Req', 'layout b=0 si so cj')
  3028.           call ToPIPE('Req', 'space')
  3029.           Req_DoneGad = ToPIPE('Req', 'button c gt="'OK$'"')
  3030.           call ToPIPE('Req', 'space')
  3031.         call ToPIPE('Req', 'le')
  3032.         call ToPIPE('Req', 'open')
  3033.         call ToPIPE('Req', 'id 'Req_StringGad' s=1')
  3034.  
  3035.         NewImageClass = ''
  3036.         do until eof('Req')
  3037.           call ToPIPE('Req', 'continue')
  3038.           Req_EventInfo = readln('Req')
  3039.           parse var Req_EventInfo Req_Event' 'Req_GadID' 'Req_GadInfo1
  3040.           if Req_Event == 'close' then NewImageClass = ReadCAGad('Req', Req_StringGad)
  3041.           if Req_GadID == Req_StringGad then NewImageClass = Req_GadInfo1
  3042.         end
  3043.         call close('Req')
  3044.         call ToPIPE('CA', 'id 0 s=512')
  3045.  
  3046.         if NewImageClass ~= '' then do
  3047.           ImageClass.ImgClassCount = NewImageClass
  3048.           NewImageFile = ''
  3049.           interpret "ImageFile."ImgClassCount" = NewImageFile"
  3050.           ImgClassCount = ImgClassCount + 1
  3051.  
  3052.           MiscVarName.MiscVarCount = 'ImageClass.'NewImageClass
  3053.           UpdateVarCmd.UpdateVarCmds = 'id 'MiscVarListID' addnode tar=-1 gt="ImageClass.'NewImageClass'"'
  3054.           UpdateVarNum.UpdateVarCmds = MiscVarCount
  3055.           UpdateVarCmds = UpdateVarCmds + 1
  3056.           MiscVarCount = MiscVarCount + 1
  3057.  
  3058.           MiscVarName.COUNT  = MiscVarCount
  3059.           ImageClass.COUNT   = ImgClassCount
  3060.           CurrentMiscName    = 'ImageClass.'NewImageClass
  3061.  
  3062.           call UpdateMiscVarGad
  3063.         end
  3064.       end
  3065.     /**/
  3066.  
  3067.       otherwise do
  3068.     /***//*** MX Gads ***/
  3069.         if symbol('DSR_Gad.DSR_GadID') == 'VAR' then do
  3070.           parse var DSR_Gad.DSR_GadID .'.'DSR_Grp'.'DSR_Posn
  3071.           if DSR_Grp ~= '' then call ControlMX(DSR_Grp, DSR_Posn)
  3072.         end
  3073.     /**/
  3074.       end
  3075.     end
  3076.     if (DSR_Event = 'gadget') & (ShiftDown = 1) & (symbol('GadText.DSR_GadID.1') == 'VAR') then do
  3077.       ShiftedGad = DSR_GadID
  3078.       OverGad = DSR_GadID
  3079.       call ToPIPE('CA', 'id 'ShiftedGad' gt="'GadText.ShiftedGad.1'"')
  3080.     end
  3081.   end
  3082.  
  3083.   Margin.Top    = ReadCAGad('CA', TopMargGad)
  3084.   Margin.Left   = ReadCAGad('CA', LeftMargGad)
  3085.   Margin.Right  = ReadCAGad('CA', RightMargGad)
  3086.   Margin.Bottom = ReadCAGad('CA', BottomMargGad)
  3087.  
  3088.   return
  3089.   /**/
  3090.  
  3091. /***//*** CA_Interpret MX ***/
  3092. CA_InterpretMX:
  3093.   do DSR_Posn = 0 to PosnCount
  3094.     interpret "Do"Do.DSR_Posn" = ''"
  3095.   end
  3096.   do DSR_Grp = 0 to GroupCount
  3097.     DSR_Posn = DSR_Sel.DSR_Grp
  3098.     interpret "Do"Do.DSR_Posn" = translate(DSR_Grp, 'BBBTT', '01234')||translate(DSR_Grp, 'LCRCR', '01234')"
  3099.   end
  3100.  
  3101.   if DoBothJ ~= '' then do
  3102.     DoJulian = DoBothJ
  3103.     DoJulianLeft = DoBothJ
  3104.   end
  3105.   if DoBothS ~= '' then do
  3106.     DoSunrise = DoBothS
  3107.     DoSunset = DoBothS
  3108.   end
  3109.   TopOption = sign(pos('T', DoPhases''DoWeeknumber''DoJulian''DoJulianLeft''DoSunrise''DoSunset))
  3110.  
  3111.   return
  3112. /**/
  3113.  
  3114. /***//*** ProcessMiscValGad ***/
  3115. ProcessMiscValGad:
  3116.   parse arg Value
  3117.   if datatype(Value) == 'CHAR' then Value = QuoteIt(Value)
  3118.   interpret CurrentMiscName' = 'Value
  3119.   if (upper(CurrentMiscName) == 'PREFSNAME') then do
  3120.     if PrefsName == '' then PrefsName = PrefsFile
  3121.     call ToPIPE('CA', 'id 'DisplayNameGad' gt="'value(CurrentMiscName)'" ref')
  3122.   end
  3123.   if HostScreen ~= '' then AppScreen = HostScreen
  3124.  
  3125.   return
  3126. /**/
  3127.  
  3128. /***//*** ReadMonthYearGads ***/
  3129. ReadMonthYearGads:
  3130.   if CalType == 1 then do
  3131.     Month = ReadCAGad('CA', SwitchGad1) + 1
  3132.     EnteredYear = ReadCAGad('CA', SwitchGad2)
  3133.   end
  3134.   else if CalType == 2 then do
  3135.     Month = ReadCAGad('CA', SwitchGad1) + 1
  3136.     EndMonth = ReadCAGad('CA', SwitchGad2) + 1
  3137.     EnteredYear = ReadCAGad('CA', SwitchGad3)
  3138.   end
  3139.   else EnteredYear = ReadCAGad('CA', SwitchGad2)
  3140.  
  3141.   return
  3142. /**/
  3143.  
  3144. /***//*** UpdateMiscVarGad ***/
  3145. UpdateMiscVarGad:
  3146.   call ToPIPE('CA', 'id 'MiscVarGad' gt="'CurrentMiscName'" page='ClickTab)
  3147.   if upper(left(CurrentMiscName, pos('.', CurrentMiscName))) == 'IMAGECLASS.' then do
  3148.     IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  3149.     call ToPIPE('CA', 'id 'MiscValGad' gt="'value("ImageFile.IC")'" page='ClickTab' refresh')
  3150.   end
  3151.   else call ToPIPE('CA', 'id 'MiscValGad' gt="'value(CurrentMiscName)'" page='ClickTab' refresh')
  3152.   UCMN = upper(CurrentMiscName)
  3153.   if (left(UCMN, 11) == 'IMAGECLASS.') | (UCMN == 'GFXAPPPATH') | (UCMN == 'SUNCALCPATH') | (UCMN == 'GFXAPP') then VarReqGad = 0
  3154.   else VarReqGad = 1
  3155.   call ToPIPE('CA', 'id 'ChooseValGad' dis='VarReqGad' page='ClickTab' refresh')
  3156.  
  3157.   return
  3158. /**/
  3159.  
  3160. /***//*** CA_UpdateGads ***/
  3161. CA_UpdateGads:
  3162.   if show('F', 'ProgReq') == 0 then Req = OpenBusy(PrepReq$, 12)
  3163.   call ToPIPE('CA', 'id 0 s=256')
  3164.   FontVarList     = ''
  3165.   ColorVarList    = ''
  3166.   CurrentColor    = 0
  3167.   CalType         = 1
  3168.   Month           = CalMonth
  3169.   EndMonth        = 12
  3170.   EnteredYear     = Year
  3171.   FontReq         = 0
  3172.   MiscVarReq      = 0
  3173.   ColorVarReq     = 0
  3174.   CurrentColorNum = 0
  3175.   CurrentMiscNum  = 0
  3176.   OverGad         = 0
  3177.   ShiftDown       = 0
  3178.   ShiftedGad      = 0
  3179.  
  3180.   DoBothS  = ''
  3181.   DoBothJ  = ''
  3182.  
  3183.   WarningCount = WarningsSoFar
  3184.   call ReadData
  3185.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3186.  
  3187.   UCMN = upper(CurrentMiscName)
  3188.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3189.  
  3190.   if DoExtended == 1 then do
  3191.     DoTopExtraWk = 0
  3192.     DoTopExtraWkDis = 1
  3193.     DoNoteBox = 0
  3194.     DoNoteBoxDis = 1
  3195.   end
  3196.   else do
  3197.     DoTopExtraWkDis = 0
  3198.     DoNoteBoxDis = 0
  3199.   end
  3200.  
  3201.   if (PrefsName == 'Default') & (PrefsFile ~= 'Default') then DisplayName = PrefsFile
  3202.   else DisplayName = PrefsName
  3203.  
  3204.   do DSR_Posn = 1 to PosnCount
  3205.     if (DSR_Posn == PhasesPosn) & (PhaseLib ~= 1) then iterate
  3206.     if (DSR_Posn == SunrisePosn) & (exists(Storage'suncalc') == 0) then iterate
  3207.     if (DSR_Posn == SunsetPosn) & (exists(Storage'suncalc') == 0) then iterate
  3208.     if (DSR_Posn == BothSPosn) & (exists(Storage'suncalc') == 0) then iterate
  3209.     if (DSR_Posn == RandomPosn) & (exists(ScriptDir'FWCRandom.txt') == 0) then iterate
  3210.     if (DSR_Posn == HistoryPosn) & (exists(ScriptDir'FWCHistory/01') == 0) then iterate
  3211.     interpret 'DoVariable = "Do'Do.DSR_Posn'"'
  3212.     if value(DoVariable) == 0 then interpret DoVariable " = ''"
  3213.     if value(DoVariable) ~= '' then do
  3214.       interpret DoVariable' = right(value(DoVariable), 2, "B")'
  3215.       DSR_Grp = translate(left(value(DoVariable), 1), '02', 'BT') + translate(right(value(DoVariable), 1), '012', 'LCR')
  3216.       GadSel.DSR_Grp.DSR_Posn = 1
  3217.       DSR_Sel.DSR_Grp = DSR_Posn
  3218.     end
  3219.   end
  3220.  
  3221.   do DSR_Grp = 0 to GroupCount
  3222.     if (GadSel.DSR_Grp.SunsetPosn == GadSel.DSR_Grp.SunrisePosn) & (GadSel.DSR_Grp.SunsetPosn == 1) then do
  3223.        GadSel.DSR_Grp.SunsetPosn  = 0
  3224.        GadSel.DSR_Grp.SunrisePosn = 0
  3225.        GadSel.DSR_Grp.BothSPosn   = 1
  3226.        DSR_Sel.DSR_Grp = BothSPosn
  3227.     end
  3228.     else if (GadSel.DSR_Grp.JulianPosn == GadSel.DSR_Grp.JulianLeftPosn) & (GadSel.DSR_Grp.JulianPosn == 1) then do
  3229.        GadSel.DSR_Grp.JulianPosn     = 0
  3230.        GadSel.DSR_Grp.JulianLeftPosn = 0
  3231.        GadSel.DSR_Grp.BothJPosn      = 1
  3232.        DSR_Sel.DSR_Grp = BothJPosn
  3233.     end
  3234.   end
  3235.  
  3236.   do DSR_Grp = 0 to GroupCount
  3237.     DSR_Posn = DSR_Sel.DSR_Grp
  3238.     GadSel.DSR_Grp.DSR_Posn = 1
  3239.   end
  3240.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3241.  
  3242.   call close('MiscVarReq')
  3243.   call open('MiscVarReq', "awnpipe:MiscVarReq/xc")
  3244.   call ToPIPE('MiscVarReq', 'm dg v db a ps="'AppScreen'"')
  3245.   MiscVarListID = ToPIPE('MiscVarReq', 'listbrowser minw=200 minh=300')
  3246.   do DSR_i = 0 to MiscVarName.Count - 1
  3247.     GadID = ToPIPE('MiscVarReq', 'browsernode gt="'MiscVarName.DSR_i'"')
  3248.     interpret 'MiscVarGad.'GadID' = 'DSR_i
  3249.   end
  3250.   call UpdateMiscVarGad
  3251.  
  3252.   call close('ColorVarReq')
  3253.   call open('ColorVarReq', "awnpipe:ColorVarReq/xc")
  3254.   call ToPIPE('ColorVarReq', 'm dg v db a ps="'AppScreen'"')
  3255.   call ToPIPE('ColorVarReq', 'listbrowser minw=200 minh=300')
  3256.   do DSR_i = 0 to ColorVarName.Count - 1
  3257.     GadID = ToPIPE('ColorVarReq', 'browsernode gt="'ColorVarName.DSR_i'"')
  3258.     interpret 'ColorVarGad.'GadID' = 'DSR_i
  3259.   end
  3260.  
  3261.   do DSR_i = 0 to FontVarName.Count - 1
  3262.     FontVarList = FontVarList''FontVarName.DSR_i'|'
  3263.   end
  3264.  
  3265.   FontVarList = '"'strip(FontVarList, 'B', '|')'"'
  3266.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3267.  
  3268.   call ToPIPE('CA', 'id 'DisplayNameGad' gt="'DisplayName'" ref')
  3269.   call ToPIPE('CA', 'id 'MiniCalsGad' s='DoMiniCals' page='ClickTab' ref')
  3270.   call ToPIPE('CA', 'id 'HighlightsGad' s='DoHighlights' page='ClickTab' ref')
  3271.   call ToPIPE('CA', 'id 'ImagesGad' dis='GfxDisable' s='DoImages' page='ClickTab' ref')
  3272.   call ToPIPE('CA', 'id 'BoxDatesGad' s='DoDateBox' page='ClickTab' ref')
  3273.   call ToPIPE('CA', 'id 'ExtendedGad' s='DoExtended' page='ClickTab' ref')
  3274.   call ToPIPE('CA', 'id 'TopLongGad' dis='DoTopExtraWkDis' s='DoTopExtraWk' page='ClickTab' ref')
  3275.   call ToPIPE('CA', 'id 'NoteBoxGad' dis='DoNoteBoxDis' s='DoNoteBox' page='ClickTab' ref')
  3276.   call ToPIPE('CA', 'id 'TopMargGad' gt="'Margin.Top'" page='ClickTab' ref')
  3277.   call ToPIPE('CA', 'id 'LeftMargGad' gt="'Margin.Left'" page='ClickTab' ref')
  3278.   call ToPIPE('CA', 'id 'OrientationGad' s='OrientChoice' page='ClickTab' ref')
  3279.   call ToPIPE('CA', 'id 'RightMargGad' gt="'Margin.Right'" page='ClickTab' ref')
  3280.   call ToPIPE('CA', 'id 'BottomMargGad' gt="'Margin.Bottom'" page='ClickTab' ref')
  3281.  
  3282.   call ToPIPE('CA', 'id 'CalendarTypeGad' s=0 ref')
  3283.   call AssignID('SwitchGad1', ToPIPE('CA', 'define chooser replace='SwitchGad1' pu cl='MonthList' s='Month - 1))
  3284.   call AssignID('SwitchGad2', ToPIPE('CA', 'define integer replace='SwitchGad2' a tc weiw=5 maxc=4 defn='EnteredYear))
  3285.   call AssignID('SwitchGad3', ToPIPE('CA', 'define button replace='SwitchGad3' b=0 gt=""'))
  3286.   call ToPIPE('CA', 'refresh')
  3287.   Help$.SwitchGad1Help = Help$.MonthGadHelp
  3288.   Help$.SwitchGad2Help = Help$.YearGadHelp
  3289.   Help$.SwitchGad3Help = ''
  3290.   call ToPIPE('CA', 'id 'SwitchGad1' s='Month - 1' ref')
  3291.   call ToPIPE('CA', 'id 'SwitchGad2' defn='EnteredYear' ref')
  3292.  
  3293.   call ToPIPE('CA', 'id 'FontVarGad' defn='FontVarName.COUNT' cl='FontVarList' page='ClickTab' ref')
  3294.   call ToPIPE('CA', 'id 'FontValGad' gt="'value(CurrentFontName)'" page='ClickTab' ref')
  3295.   call ToPIPE('CA', 'id 'ColorVarGad' gt="'CurrentColorName'" page='ClickTab' ref')
  3296.   call ToPIPE('CA', 'id 'ColorValGad' gt="'value(CurrentColorName)'" page='ClickTab' ref')
  3297.   call ToPIPE('CA', 'id 'MatchColorsGad' s='DoMatchColors' page='ClickTab' ref')
  3298.   call ToPIPE('CA', 'id 'DailyColorsGad' s='DoDailyColors' page='ClickTab' ref')
  3299.   call ToPIPE('CA', 'id 'MiscVarGad' gt="'CurrentMiscName'" page='ClickTab' ref')
  3300.   call ToPIPE('CA', 'id 'MiscValGad' gt="'VarVal'" page='ClickTab' ref')
  3301.   call ToPIPE('CA', 'id 'ChooseValGad' dis='VarReqGad' page='ClickTab' ref')
  3302.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3303.  
  3304.   do DSR_Grp = 0 to GroupCount
  3305.     do DSR_Posn = 0 to PosnCount
  3306.       if datatype(Gad.DSR_Grp.DSR_Posn) == 'NUM' then call ToPIPE('CA', 'id 'Gad.DSR_Grp.DSR_Posn' dis='GadDis.DSR_Grp.DSR_Posn' s='GadSel.DSR_Grp.DSR_Posn' page='ClickTab' ref')
  3307.     end
  3308.     call ControlMX(DSR_Grp, DSR_Sel.DSR_Grp)
  3309.     if PhaseLib ~= 1 then call ToPIPE('CA', 'id 'Gad.DSR_Grp.PhasesPosn' dis=1 page='ClickTab' ref')
  3310.     if (~exists(ScriptDir'FWCRandom.txt')) & (datatype(Gad.DSR_Grp.RandomPosn) == 'NUM') then
  3311.       call ToPIPE('CA', 'id 'Gad.DSR_Grp.RandomPosn' dis=1 page='ClickTab' ref')
  3312.     if ~exists(ScriptDir'FWCHistory/01') & (datatype(Gad.DSR_Grp.HistoryPosn) == 'NUM') then
  3313.       call ToPIPE('CA', 'id 'Gad.DSR_Grp.HistoryPosn' dis=1 page='ClickTab' ref'))
  3314.     if ~exists(Storage'suncalc') then do
  3315.       call ToPIPE('CA', 'id 'Gad.DSR_Grp.SunRisePosn' dis=1 page='ClickTab' ref')
  3316.       call ToPIPE('CA', 'id 'Gad.DSR_Grp.SunSetPosn' dis=1 page='ClickTab' ref')
  3317.       call ToPIPE('CA', 'id 'Gad.DSR_Grp.BothSPosn' dis=1 page='ClickTab' ref')
  3318.     end
  3319.   end
  3320.   call ToPIPE('CA', 'id 0 s=512')
  3321.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3322.  
  3323.   call close('ProgReq')
  3324.   return
  3325. /**/
  3326.  
  3327. /**/
  3328.  
  3329. /***//*** dTox (PROCEDURE) ***/
  3330. dTox:PROCEDURE
  3331. parse arg DecVal
  3332.  
  3333. BinVal = ''
  3334. HexVal = ''
  3335. do i = 32 to 0 by -1
  3336.   if DecVal >= 2**i then do
  3337.     BinVal = BinVal'1'
  3338.     DecVal = DecVal - 2**i
  3339.   end
  3340.   else BinVal = BinVal'0'
  3341. end
  3342.  
  3343. do until BinVal == ''
  3344.   HexVal = c2x(b2c(right(BinVal, 8, '0')))''HexVal
  3345.   if length(BinVal) >= 8 then CutLength = 8
  3346.   else CutLength = length(BinVal)
  3347.   BinVal = left(BinVal, length(BinVal) - CutLength)
  3348. end
  3349.  
  3350. return HexVal
  3351. /**/
  3352.  
  3353. /***//*** DrawBox (DB) ***/
  3354. DrawBox:
  3355.   parse arg DB_x1, DB_y1, DB_width, DB_height, DB_Weight, DB_LineColor, DB_FillBool, DB_FillColor, DB_SendToBack, DB_CornerRadius
  3356.  
  3357.   if DB_FillColor == '<'Clear$'>' then DB_FillBool = 0
  3358.  
  3359.   if App == 'FW' then do
  3360.     if DB_Weight == 'HL' then DB_Weight = 'Hairline'
  3361.     else if DB_Weight == 0 then do
  3362.       DB_Weight = 'None'
  3363.       if DB_FillColor ~= '<'Clear$'>' then DB_LineColor = DB_FillColor
  3364.     end
  3365.  
  3366.     if DB_FillBool == 1 then DB_FillBool = 'Solid'
  3367.     else do
  3368.       DB_FillBool = 'Transparent'
  3369.       DB_FillColor = DB_LineColor
  3370.     end
  3371.  
  3372.     if DB_CornerRadius == 0 then DB_BoxType = ''
  3373.     else DB_BoxType = 'BEVEL'
  3374.  
  3375.     BOXPREFS LINEWT DB_Weight LINECOLOR '"'DB_LineColor'"' FILL DB_FillBool FILLCOLOR '"'DB_FillColor'"'
  3376.     DRAWBOX 1 DB_x1 DB_y1 DB_width DB_height DB_BoxType; DB_id = result
  3377.     if DB_SendToBack == 1 then OBJECTTOBACK
  3378.   end
  3379.   else if App == 'PGS' then do
  3380.     if DB_Weight == 'HL' then DB_Weight = 0.3pt
  3381.     else DB_Weight = DB_Weight'pt'
  3382.  
  3383.     if DB_FillBool == 1 then DB_FillBool = 'ON'
  3384.     else DB_FillBool = 'OFF'
  3385.  
  3386.     If DB_Weight == 0 then DB_LineBool = 'OFF'
  3387.     else DB_LineBool = 'ON'
  3388.  
  3389.     if DB_CornerRadius == 0 then DB_BoxType = 'NORMAL'
  3390.     else DB_BoxType = 'ROUND'
  3391.  
  3392.     DRAWBOX DB_x1 DB_y1 DB_x1+DB_width DB_y1+DB_height DB_BoxType CORNER DB_CornerRadius WINDOW winName; DB_id = result
  3393.     STROKED DB_LineBool OBJECT WINDOW winName
  3394.     SETSTROKEWEIGHT DB_Weight STROKENUMBER 0 OBJECT WINDOW winName
  3395.     SETCOLORSTYLE '"'DB_LineColor'"' COLORNUMBER 0 STROKENUMBER 0 OBJECT WINDOW winName
  3396.     FILLED DB_FillBool OBJECT WINDOW winName
  3397.     SETCOLORSTYLE '"'DB_FillColor'"' COLORNUMBER 0 FILL OBJECT WINDOW winName
  3398.     if DB_SendToBack == 1 then SENDTOBACK OBJECTID DB_id WINDOW winName
  3399.   end
  3400.  
  3401.   return DB_id
  3402. /**/
  3403.  
  3404. /***//*** DrawHalf (DH) ***/
  3405. DrawHalf:
  3406.   parse arg DH_Side
  3407.  
  3408.   if App == 'FW' then do
  3409.     if DH_Side == 'L' then DH_sign = -1
  3410.     else DH_sign = 1
  3411.  
  3412.     STARTPATH 1 DM_CtrX (DM_CtrY + MoonRadius)
  3413.     CURVETO 1 (DM_CtrX + (DH_sign * MoonRadius * BelzierFactor)) (DM_CtrY + MoonRadius) (DM_CtrX + (DH_sign * MoonRadius)) (DM_CtrY + MoonRadius * BelzierFactor) (DM_CtrX + (DH_sign * MoonRadius)) DM_CtrY
  3414.     CURVETO 1 (DM_CtrX + (DH_sign * MoonRadius)) (DM_CtrY - MoonRadius * BelzierFactor) (DM_CtrX + (DH_sign * MoonRadius * BelzierFactor)) (DM_CtrY - MoonRadius) DM_CtrX (DM_CtrY - MoonRadius)
  3415.     ENDPATH Close
  3416.   end
  3417.   else if App == 'PGS' then do
  3418.     if DH_Side == 'L' then DRAWELLIPSE DM_CtrX DM_CtrY MoonRadius MoonRadius PIE ANGLES 90 270 WINDOW winName
  3419.     else DRAWELLIPSE DM_CtrX DM_CtrY MoonRadius MoonRadius PIE ANGLES 270 90 WINDOW winName
  3420.   end
  3421.  
  3422.   return result
  3423. /**/
  3424.  
  3425. /***//*** DrawLine (DL) ***/
  3426. DrawLine:
  3427.   parse arg DL_x1, DL_y1, DL_x2, DL_y2, DL_Weight, DL_Color
  3428.  
  3429.   if App == 'FW' then do
  3430.     if DL_Weight == 'HL' then DL_Weight = 'Hairline'
  3431.     else if DL_Weight == 0 then DL_Weight = 'None'
  3432.  
  3433.     LINEPREFS LINEWT DL_Weight LINECOLOR '"'DL_Color'"'
  3434.     DRAWLINE 1 DL_x1 DL_y1 DL_x2 DL_y2
  3435.   end
  3436.   else if App == 'PGS' then do
  3437.     if DL_Weight == 'HL' then DL_Weight = '0.3pt'
  3438.     else DL_Weight = DL_Weight'pt'
  3439.  
  3440.     DRAWLINE DL_x1 DL_y1 DL_x2 DL_y2 WINDOW winName; DL_id = result
  3441.     STROKED ON OBJECT WINDOW winName
  3442.     SETSTROKEWEIGHT DL_Weight STROKENUMBER 0 OBJECT
  3443.     SETCOLORSTYLE '"'DL_Color'"' COLORNUMBER 0 STROKENUMBER 0 OBJECT WINDOW winName
  3444.   end
  3445.  
  3446.   return result
  3447. /**/
  3448.  
  3449. /***//*** DrawMiniCal (DMC) ***/
  3450. DrawMiniCal:
  3451.   parse arg DMC_MiniDirection, DMC_CalWidth, DMC_FontType
  3452.  
  3453.   DMC_ColumnWidth = DMC_CalWidth/8
  3454.   DMC_BoxCount = 0
  3455.  
  3456.   DMC_MiniMonth = Month + DMC_MiniDirection
  3457.   if DMC_MiniMonth == 0 | DMC_MiniMonth == 13 then do
  3458.     DMC_MiniMonth = abs(DMC_MiniMonth - 12)
  3459.     Year = EnteredYear + DMC_MiniDirection
  3460.   end
  3461.   else Year = EnteredYear
  3462.   Mn = right(DMC_MiniMonth, 2, '0')
  3463.   if DoHighlights == 1 then call SetHighlights
  3464.  
  3465.   if DMC_MiniDirection < 0 then do
  3466.     DMC_StartColumn = StartDate - MonthLength.DMC_MiniMonth//7
  3467.     If DMC_StartColumn < 0 then DMC_StartColumn = DMC_StartColumn + 7
  3468.     DMC_MiniCalLeft = Margin.Left + ShiftLMini - CalendarBorder
  3469.   end
  3470.   else if DMC_MiniDirection > 0 then do
  3471.     DMC_StartColumn = StartDate + MonthLength.Month//7
  3472.     If DMC_StartColumn > 6 then DMC_StartColumn = DMC_StartColumn - 7
  3473.     DMC_MiniCalLeft = FullWidth - Margin.Right - DMC_CalWidth + ShiftRMini - CalendarShadow
  3474.   end
  3475.   else do
  3476.     DMC_StartColumn = StartDate
  3477.     DMC_MiniCalLeft = Margin.Left + c * (DMC_CalWidth + MiniCalSpacing)
  3478.   end
  3479.  
  3480.   /* Print Month & Year */
  3481.   DMC_ID.0 = CenterText(PrintText(1, Margin.Top, DMC_FontType, 'N', Color.MiniCal, Width.DMC_FontType, Month.DMC_MiniMonth' 'Year), DMC_MiniCalLeft + DMC_CalWidth/2, DMC_CalWidth, 0)
  3482.  
  3483.   /* Print Days */
  3484.   DMC_Column = DMC_StartColumn
  3485.   DMC_Day = 0
  3486.   DMC_Row = 1
  3487.   Do Until DMC_Day = MonthLength.DMC_MiniMonth
  3488.     DMC_Day = DMC_Day + 1
  3489.     DMC_Char1 = left(right(DMC_Day, 2, ' '), 1)
  3490.     DMC_Char2 = right(DMC_Day, 1)
  3491.     if (Highlight.DMC_MiniMonth.DMC_Day == '') | (symbol('Highlight.DMC_MiniMonth.DMC_Day') == 'LIT') then do
  3492.       DMC_Style = 'N'
  3493.       if CenterMiniDates == 1 then DMC_CenterAdj = (DMC_ColumnWidth - 2*NormalWidth.Widest)/2 + (NormalWidth.Widest * 2 - NormalWidth.DMC_Char1 - NormalWidth.DMC_Char2) / 2 + NormalWidth.DMC_Char1 + NormalWidth.DMC_Char2
  3494.       else DMC_CenterAdj = (DMC_ColumnWidth - 2*NormalWidth.Widest)/2 + (NormalWidth.Widest - NormalWidth.DMC_Char2) / 2 + NormalWidth.DMC_Char1 + NormalWidth.DMC_Char2
  3495.     end
  3496.     else do
  3497.       DMC_Style = 'B'
  3498.       if CenterMiniDates == 1 then DMC_CenterAdj = (DMC_ColumnWidth - 2*BoldWidth.Widest)/2 + (BoldWidth.Widest * 2 - BoldWidth.DMC_Char1 - BoldWidth.DMC_Char2) / 2 + BoldWidth.DMC_Char1 + BoldWidth.DMC_Char2
  3499.       else DMC_CenterAdj = (DMC_ColumnWidth - 2*BoldWidth.Widest)/2 + (BoldWidth.Widest - BoldWidth.DMC_Char2) / 2 + BoldWidth.DMC_Char1 + BoldWidth.DMC_Char2
  3500.     end
  3501.  
  3502.     DMC_Text.Right = (DMC_Column + 1.5) * DMC_ColumnWidth
  3503.     DMC_Text.Top   = Margin.Top + DMC_Row*Height.DMC_FontType
  3504.  
  3505.     DMC_Text.Left = DMC_MiniCalLeft + DMC_Text.Right - DMC_CenterAdj
  3506.     DMC_ID.DMC_Day = PrintText(DMC_Text.Left, DMC_Text.Top, DMC_FontType, DMC_Style, Color.MiniCal, Width.DMC_FontType, DMC_Day)
  3507.     if UpdateBusy(Req, 1) == -1 then call Cleanup
  3508.  
  3509.     if pos('#', Highlight.DMC_MiniMonth.DMC_Day) > 0 then do
  3510.       DMC_BoxCount = DMC_BoxCount + 1
  3511.       DMC_Box.Left = DMC_MiniCalLeft + (DMC_Column + .5) * DMC_ColumnWidth
  3512.       DMC_BoxID.DMC_BoxCount = DrawBox(DMC_Box.Left, DMC_Text.Top - (Height.DMC_FontType * ((1 - TextAdj) / 3) * (App == 'FW')), DMC_ColumnWidth, Height.DMC_FontType, 'HL', Line.MiniCal, 0, Black$, 1, 0)
  3513.       call BuryObject(DMC_BoxID.DMC_BoxCount)
  3514.     end
  3515.  
  3516.     DMC_Column = DMC_Column + 1
  3517.     if DMC_Column == 7 then do
  3518.       DMC_Column = 0
  3519.       DMC_Row = DMC_Row + 1
  3520.     end
  3521.   end
  3522.  
  3523.   if CalendarShadow ~= 0 then do
  3524.     if ShadowType == 'P' then do
  3525.       call DrawBox(DMC_MiniCalLeft + DMC_CalWidth, Margin.Top + CalendarShadow, CalendarShadow, 7*Height.DMC_FontType, 0, , 1, Background.MiniCalShadow, 1, 0)
  3526.       call DrawBox(DMC_MiniCalLeft + CalendarShadow, Margin.Top + 7*Height.DMC_FontType, DMC_CalWidth, CalendarShadow, 0, , 1, Background.MiniCalShadow, 1, 0)
  3527.     end
  3528.     else call DrawBox(DMC_MiniCalLeft + CalendarShadow, Margin.Top + CalendarShadow, DMC_CalWidth, 7*Height.DMC_FontType, 0, , 1, Background.MiniCalShadow, 1, CornerRadius * MiniCalWidth)
  3529.   end
  3530.   call DrawBox(DMC_MiniCalLeft, Margin.Top, DMC_CalWidth, 7*Height.DMC_FontType, 'HL', Line.MiniCal, 1, Background.MiniCal, 1, CornerRadius * MiniCalWidth)
  3531.  
  3532.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3533.  
  3534.   if App == 'FW' then do
  3535.     REDRAW
  3536.     do DMC_i = 0 to MonthLength.DMC_MiniMonth; SELECTOBJECT DMC_ID.DMC_i MULTIPLE; End
  3537.     do DMC_i = 1 to DMC_BoxCount; SELECTOBJECT DMC_BoxID.DMC_i MULTIPLE; End
  3538.     GROUP
  3539.   end
  3540.   else if App == 'PGS' then do
  3541.     do DMC_i = 0 to MonthLength.DMC_MiniMonth; SELECTOBJECT ObjectID DMC_ID.DMC_i Add WINDOW winName; End
  3542.     do DMC_i = 1 to DMC_BoxCount; SELECTOBJECT ObjectID DMC_BoxID.DMC_i Add WINDOW winName; End
  3543.     GROUP WINDOW winName
  3544.   end
  3545. return
  3546. /**/
  3547.  
  3548. /***//*** DrawMoon (DM) ***/
  3549. DrawMoon:
  3550.   parse arg DM_Phase, DM_CtrX, DM_CtrY, DM_Color
  3551.  
  3552.   if App == 'FW' then do
  3553.     if (DM_Phase == 'N') | (DM_Phase == 'F') then do
  3554.       if DM_Phase == 'N' then DM_FillColor = DM_Color
  3555.       else DM_FillColor = White$
  3556.       OVALPREFS LINEWT 'Hairline' LINECOLOR '"'DM_Color'"' FILL 'Solid' FILLCOLOR '"'DM_FillColor'"'
  3557.       DRAWOVAL 1 (DM_CtrX - MoonRadius) (DM_CtrY - MoonRadius) (2 * MoonRadius) (2 * MoonRadius)
  3558.       DM_id = result
  3559.     end
  3560.     else do
  3561.       SHAPEPREFS LINEWT 'Hairline' LINECOLOR '"'DM_Color'"' FILL 'Solid' FILLCOLOR '"'DM_Color'"'
  3562.       if DM_Phase == 1 then DM_HalfID = DrawHalf('R')
  3563.       else DM_HalfID = DrawHalf('L')
  3564.       SHAPEPREFS FILLCOLOR '"'White$'"'
  3565.       if DM_Phase == 1 then DM_Half2ID = DrawHalf('L')
  3566.       else DM_Half2ID = DrawHalf('R')
  3567.       SELECTOBJECT DM_HalfID
  3568.       SELECTOBJECT DM_Half2ID Multiple
  3569.       GROUP
  3570.       CURRENTOBJECT; DM_id = result
  3571.     end
  3572.   end
  3573.   else if App == 'PGS' then do
  3574.     if (DM_Phase == 'N') | (DM_Phase == 'F') then do
  3575.       DRAWELLIPSE DM_CtrX DM_CtrY MoonRadius MoonRadius WINDOW winName
  3576.       DM_id = result
  3577.       if DM_Phase == 'N' then call SetFill(DM_id, DM_Color, DM_Color)
  3578.       else call SetFill(DM_id, DM_Color, White$)
  3579.     end
  3580.     else do
  3581.       DRAWELLIPSE DM_CtrX DM_CtrY MoonRadius MoonRadius PIE ANGLES 90 270 WINDOW winName
  3582.       DM_LHalfID = result
  3583.       if DM_Phase == 1 then call SetFill(DM_LHalfID, DM_Color, White$)
  3584.       else call SetFill(DM_LHalfID, DM_Color, DM_Color)
  3585.       DRAWELLIPSE DM_CtrX DM_CtrY MoonRadius MoonRadius PIE ANGLES 270 90 WINDOW winName
  3586.       DM_RHalfID = result
  3587.       if DM_Phase == 1 then call SetFill(DM_RHalfID, DM_Color, DM_Color)
  3588.       else call SetFill(DM_RHalfID, DM_Color, White$)
  3589.       SELECTOBJECT OBJECTID DM_LHalfID Add WINDOW winName
  3590.       GROUP WINDOW winName; DM_id = result
  3591.     end
  3592.   end
  3593.  
  3594.   return DM_id
  3595. /**/
  3596.  
  3597. /***//*** EditHighlight ***/
  3598. /***//*** EditHighlight_BGUI (EH) ***/
  3599. EditHighlight_BGUI:
  3600.   /***//*** Initialize Variables ***/
  3601.   EH_WeekendCyc.0     = "OK"
  3602.   EH_WeekendCyc.1     = "P"
  3603.   EH_WeekendCyc.2     = "N"
  3604.   EH_WeekendCyc.OK    = 0
  3605.   EH_WeekendCyc.P     = 1
  3606.   EH_WeekendCyc.N     = 2
  3607.  
  3608.   EH_WeekTypeCyc.0    = "All"
  3609.   EH_WeekTypeCyc.1    = "Odd"
  3610.   EH_WeekTypeCyc.2    = "Even"
  3611.   EH_WeekTypeCyc.All  = 0
  3612.   EH_WeekTypeCyc.Odd  = 1
  3613.   EH_WeekTypeCyc.Even = 2
  3614.  
  3615.   EH_HighlightTypeCyc.Fixed      = 0
  3616.   EH_HighlightTypeCyc.Float      = 1
  3617.   EH_HighlightTypeCyc.BiOrWeekly = 2
  3618.   EH_HighlightTypeCyc.0          = 'Fixed'
  3619.   EH_HighlightTypeCyc.1          = 'Float'
  3620.   EH_HighlightTypeCyc.2          = 'BiOrWeekly'
  3621.  
  3622.   EH_KeywordCode.00 = 'Highlight'
  3623.   EH_KeywordCode.01 = 'Image'
  3624.   EH_KeywordCode.10 = 'CalculateDate'
  3625.   EH_KeywordCode.11 = 'CalculateImage'
  3626.   EH_KeywordCode.20 = 'CalculateDate'
  3627.   EH_KeywordCode.21 = 'CalculateImage'
  3628.  
  3629.   EH_EntryCount   = 0
  3630.   EH_EventDay     = 0
  3631.  
  3632.   EH_Year = left(date('S'),4)
  3633.   interpret 'EH_StartYear = Day.'DateInfo('W', EH_Year'0101', 'S')
  3634.   EH_YearOffset = 7 - EH_StartYear
  3635.   if EH_YearOffset == 7 then EH_YearOffset = 0
  3636.  
  3637.   EH_SelectMonth = right(EH_SelectMonth, 2, '0')
  3638.   EH_MonthCount = MonthCount.EH_SelectMonth
  3639.   EH_Month = EH_SelectMonth - 0
  3640.   if EH_Month > 12 then EH_Month = 1
  3641.   EH_Month = right(EH_Month, 2, "0")
  3642.   EH_ShortMonth = EH_Month - 0
  3643.  
  3644.   interpret 'EH_StartDate = Day.'DateInfo('W', EH_Year''EH_Month'01', 'S')
  3645. /**/
  3646.  
  3647.   /***//*** EH_ReadData ***/
  3648.   /* Read data here */
  3649.   if EH_MonthCount > 0 then do
  3650.     do EH_j = 1 to EH_MonthCount
  3651.       EH_EntryCount = EH_EntryCount + 1
  3652.       if EH_SelectMonth < 14 then CurrentData.EH_SelectMonth.EH_j = substr(HighlightData.EH_SelectMonth.EH_j, 3)
  3653.       else CurrentData.EH_SelectMonth.EH_j = HighlightData.EH_SelectMonth.EH_j
  3654.       if symbol('CurrentData.EH_SelectMonth.EH_j') == 'VAR' then do
  3655.         EH_HighlightData = strip(CurrentData.EH_SelectMonth.EH_j)
  3656.         if right(EH_HighlightData, 2) == '*/' then do
  3657.           EH_StartComment = lastpos('/*', EH_HighlightData)
  3658.           EH_Comment.EH_EntryCount = strip(substr(EH_HighlightData, EH_StartComment), 'B', ' /*')
  3659.           EH_HighlightData = strip(left(EH_HighlightData, EH_StartComment - 1))
  3660.         end
  3661.         else EH_Comment.EH_EntryCount = ''
  3662.  
  3663.         EH_Keyword = word(EH_HighlightData, 1)
  3664.         EH_FirstDot = pos('.', EH_Keyword)
  3665.         EH_FirstParen = pos('(', EH_Keyword)
  3666.         if EH_FirstDot == 0 then EH_EndOfKeyword = EH_FirstParen
  3667.         else if EH_FirstParen == 0 then EH_EndOfKeyword = EH_FirstDot
  3668.         else EH_EndOfKeyword = min(pos('.', EH_Keyword), pos('(', EH_Keyword))
  3669.         EH_Keyword.EH_EntryCount = left(EH_Keyword, EH_EndOfKeyword - 1)
  3670.         if (upper(EH_Keyword.EH_EntryCount) == 'HIGHLIGHT') | (upper(EH_Keyword.EH_EntryCount) == 'IMAGE') then do
  3671.           EH_HighlightType.EH_EntryCount = 'Fixed'
  3672.           EH_EventDay.EH_EntryCount = substr(EH_Keyword, lastpos('.', EH_Keyword) + 1)
  3673.           EH_Event.EH_EntryCount = substr(EH_HighlightData, pos('=', EH_HighlightData) + 1)
  3674.           parse var EH_Event.EH_EntryCount EH_Event.EH_EntryCount','EH_Color.EH_EntryCount
  3675.           if upper(EH_Keyword.EH_EntryCount) == 'IMAGE' then do
  3676.             if (pos(':', EH_Event.EH_EntryCount) == 0) & (pos('/', EH_Event.EH_EntryCount) == 0) then
  3677.               EH_Event.EH_EntryCount = ScriptDir'Images/'strip(EH_Event.EH_EntryCount, 'B', ' "'||"'")
  3678.           end
  3679.         end
  3680.         else do
  3681.           EH_HighlightData = strip(substr(EH_HighlightData, EH_EndOfKeyword + 1), 'B', ')')
  3682.           if EH_SelectMonth == 14 then do
  3683.             parse var EH_HighlightData EH_EventDay.EH_EntryCount','EH_Event.EH_EntryCount','EH_Color.EH_EntryCount
  3684.             EH_EventDay.EH_EntryCount = strip(EH_EventDay.EH_EntryCount)
  3685.             EH_Event.EH_EntryCount = strip(EH_Event.EH_EntryCount)
  3686.             EH_HighlightType.EH_EntryCount = 'Easter'
  3687.             EH_Keyword.EH_EntryCount = 'CalculateEDate'
  3688.           end
  3689.           else do
  3690.             parse var EH_HighlightData .','EH_DayOfWeek','EH_HighDate','EH_Event.EH_EntryCount','EH_Color.EH_EntryCount
  3691.             interpret "EH_DayOfWeek = Day."strip(EH_DayOfWeek, 'B', ' "'||"'")
  3692.             EH_HighDate = strip(EH_HighDate)
  3693.             EH_Event.EH_EntryCount = strip(EH_Event.EH_EntryCount)
  3694.             if pos('IMAGE', upper(EH_Keyword.EH_EntryCount)) > 0 then do
  3695.               if (pos(':', EH_Event.EH_EntryCount) == 0) & (pos('/', EH_Event.EH_EntryCount) == 0) then do
  3696.                 EH_Event.EH_EntryCount = ScriptDir'Images/'strip(EH_Event.EH_EntryCount, 'B', ' "'||"'")
  3697.               end
  3698.             end
  3699.             if datatype(EH_HighDate) == 'CHAR' then do
  3700.               /* Weekly/Biweekly events */
  3701.               EH_HighlightType.EH_EntryCount = 'BiOrWeekly'
  3702.               EH_WeekType.EH_EntryCount = strip(upper(EH_HighDate), 'B', "'")
  3703.               EH_EventOffset = EH_DayOfWeek - EH_StartDate
  3704.               EH_EventDay.EH_EntryCount  = 1 + EH_EventOffset
  3705.               if EH_EventDay.EH_EntryCount < 1 then EH_EventDay.EH_EntryCount = EH_EventDay.EH_EntryCount + 7
  3706.               EH_WN = trunc((right(DateInfo('J', EH_Year''EH_Month''right(EH_EventDay.EH_EntryCount, 2, '0'), 'S'), 3) - EH_YearOffset - 1)/7 + 1)
  3707.               if ((EH_WeekType.EH_EntryCount == 'EVEN') & (EH_WN//2 == 1)) | ((EH_WeekType.EH_EntryCount == 'ODD') & (EH_WN//2 == 0)) then EH_EventDay.EH_EntryCount = EH_EventDay.EH_EntryCount + 7
  3708.             end
  3709.             else do
  3710.               EH_HighlightType.EH_EntryCount = 'Float'
  3711.               interpret 'EH_First = Day.'DateInfo('W', EH_Year''EH_Month'01', 'S')
  3712.               EH_EventDay.EH_EntryCount = EH_HighDate + (EH_DayOfWeek - EH_First)
  3713.               if EH_First < EH_DayOfWeek then EH_EventDay.EH_EntryCount = EH_EventDay.EH_EntryCount - 7
  3714.               EH_TempDay = EH_EventDay.EH_EntryCount
  3715.               EH_Weeknumber.EH_EntryCount = 0
  3716.               if EH_HighDate > 28 then EH_Weeknumber.EH_EntryCount = 4
  3717.               else do
  3718.                 do until EH_TempDay < 0
  3719.                   EH_TempDay = EH_TempDay - 7
  3720.                   if EH_TempDay > 0 then EH_Weeknumber.EH_EntryCount = EH_Weeknumber.EH_EntryCount + 1
  3721.                 end
  3722.               end
  3723.             end
  3724.           end
  3725.         end
  3726.  
  3727.         if datatype(EH_EventDay.EH_EntryCount) == 'CHAR' then do
  3728.           EH_Weekend.EH_EntryCount = upper(right(EH_EventDay.EH_EntryCount, 1))
  3729.           EH_EventDay.EH_EntryCount = left(EH_EventDay.EH_EntryCount, length(EH_EventDay.EH_EntryCount) - 1)
  3730.         end
  3731.         else EH_Weekend.EH_EntryCount = 'OK'
  3732.  
  3733.         if EH_EventDay.EH_EntryCount == '32' then EH_EventDay.EH_EntryCount = 'LD'
  3734.  
  3735.         EH_Event.EH_EntryCount = strip(EH_Event.EH_EntryCount, 'B', ' "'||"'")
  3736.         if right(EH_Event.EH_EntryCount, 1) == '#' then do
  3737.           EH_Holiday.EH_EntryCount = 128
  3738.           EH_Event.EH_EntryCount = left(EH_Event.EH_EntryCount, length(EH_Event.EH_EntryCount) - 1)
  3739.         end
  3740.         else EH_Holiday.EH_EntryCount = 0
  3741.       end
  3742.       EH_Color.EH_EntryCount = strip(EH_Color.EH_EntryCount, 'B', ' "'||"'")
  3743.       EH_Color.EH_EntryCount = MemberID(EH_Color.EH_EntryCount, 'ColorList')
  3744.       if EH_Color.EH_EntryCount == -1 then EH_Color.EH_EntryCount = ColorList.COUNT
  3745.  
  3746.       do EH_k = 1 to EH_EntryCount - 1
  3747.         EH_Seq = EH_Pointer.EH_k
  3748.         if EH_EventDay.EH_EntryCount < EH_EventDay.EH_Seq then do
  3749.           do EH_l = EH_EntryCount - 1 to EH_k by -1
  3750.             EH_Next = EH_l + 1
  3751.             EH_Pointer.EH_Next = EH_Pointer.EH_l
  3752.           end
  3753.         leave
  3754.         end
  3755.       end
  3756.       EH_Pointer.EH_k = EH_EntryCount
  3757.     end
  3758.   end
  3759.  
  3760.   EH_HighEntry = EH_EntryCount
  3761.   if EH_EntryCount > 0 then do
  3762.     EH_CurrentPointer = 1
  3763.     EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  3764.   end
  3765.   else do
  3766.     EH_CurrentEntry = 0
  3767.     EH_CurrentPointer = 0
  3768.   end
  3769.   EH_DayShowing = 0
  3770.   /**/
  3771.  
  3772.   /***//*** GUI Description ***/
  3773.   GadID.  = ''
  3774.   EH_Arg. = ''
  3775.   EH_i    = 0
  3776.   EH_Day  = 0
  3777.   Req     = OpenBusy(PrepReq$, 45)
  3778.   do while (EH_i < 6)
  3779.     EH_j = 0
  3780.     do while (EH_j < 7)
  3781.       if UpdateBusy(Req, 1) == -1 then call Cleanup
  3782.       EH_SerialPosition = (EH_i * 7) + EH_j
  3783.       EH_Button = EH_SerialPosition + 1
  3784.       if (EH_SerialPosition >= EH_StartDate) & (EH_SerialPosition < EH_StartDate + MonthLength.EH_ShortMonth + 1) then Do
  3785.         EH_Day = EH_Day + 1
  3786.         if EH_Day > MonthLength.EH_ShortMonth then EH_Day = LD
  3787.         interpret "GadID."EH_Button" = bguitoggle('"EH_Button"_', EH_Day)"
  3788.         GadID = GetID(EH_Button'_')
  3789.         EH_Button.EH_Button = GadID
  3790.         EH_Arg.GadID = EH_Day
  3791.         EH_ButtonID.EH_Day = EH_Button
  3792.       end
  3793.       else do
  3794.           interpret "GadID."EH_Button" = bguibutton('"EH_Button"_', '')"
  3795.           GadID = GetID(EH_Button'_')
  3796.           EH_Button.EH_Button = GadID
  3797.           EH_Arg.GadID = 'dummy'
  3798.       end
  3799.       EH_j = EH_j + 1
  3800.     end
  3801.     EH_i = EH_i + 1
  3802.     if EH_SerialPosition >= EH_StartDate + MonthLength.EH_ShortMonth then leave
  3803.   end
  3804.  
  3805.   DateButtons = bguihgroup(GadID.1""GadID.2""GadID.3""GadID.4""GadID.5""GadID.6""GadID.7)||,
  3806.                 bguihgroup(GadID.8""GadID.9""GadID.10""GadID.11""GadID.12""GadID.13""GadID.14)||,
  3807.                 bguihgroup(GadID.15""GadID.16""GadID.17""GadID.18""GadID.19""GadID.20""GadID.21)||,
  3808.                 bguihgroup(GadID.22""GadID.23""GadID.24""GadID.25""GadID.26""GadID.27""GadID.28)
  3809.   if EH_i > 4 then DateButtons = DateButtons''bguihgroup(GadID.29""GadID.30""GadID.31""GadID.32""GadID.33""GadID.34""GadID.35)
  3810.   if EH_i > 5 then DateButtons = DateButtons''bguihgroup(GadID.36""GadID.37""GadID.38""GadID.39""GadID.40""GadID.41""GadID.42)
  3811.  
  3812.   call bguilist("EH_monthlist_", January$, February$, March$, April$, May$, June$, July$, August$, September$, October$, November$, December$, All$, Easter$)
  3813.   call bguilist("EH_highlighttypelist_", Fixed$, Floating$, BiOrWeekly$)
  3814.   call bguilist("EH_weeknumberlist_", First$, Second$, Third$, Fourth$, Last$)
  3815.   call bguilist("EH_weektypelist_", All$, Odd$, Even$)
  3816.   call bguilist("EH_weekendlist_", OK2$, PreviousDay$, NextDay$)
  3817.  
  3818.   EH_g=bguivgroup(,
  3819.     bguihgroup(,
  3820.       bguistring("EH_event_",Event$":","",256)bguilayout(LGO_FixMinHeight,1)||,
  3821.       bguiibutton('EH_eventimage_','B','F')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1)||,
  3822.       bguibutton('EH_prev_','<')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1)||,
  3823.       bguibutton("EH_next_",'>')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight,1),
  3824.     )||,
  3825.     bguihgroup(,
  3826.       bguistring('EH_comment_',Comment$":","",256)bguilayout(LGO_FixMinHeight,1),
  3827.     )||,
  3828.     bguihgroup(,
  3829.       bguivgroup(,
  3830.         bguihgroup(,
  3831.           bguivarspace(40)||,
  3832.           bguicycle('changemonth_',,"EH_monthlist_",'P')bguilayout(LGO_FixMinHeight, 1)||,
  3833.           bguivarspace(40),
  3834.         )||,
  3835.         bguihgroup(,
  3836.           bguiinfo("EH_dummy_",,esc"c"left(Day.0,1))||,
  3837.           bguiinfo("EH_dummy_",,esc"c"left(Day.1,1))||,
  3838.           bguiinfo("EH_dummy_",,esc"c"left(Day.2,1))||,
  3839.           bguiinfo("EH_dummy_",,esc"c"left(Day.3,1))||,
  3840.           bguiinfo("EH_dummy_",,esc"c"left(Day.4,1))||,
  3841.           bguiinfo("EH_dummy_",,esc"c"left(Day.5,1))||,
  3842.           bguiinfo("EH_dummy_",,esc"c"left(Day.6,1)),
  3843.         )||,
  3844.         DateButtons,
  3845.       )||,
  3846.       bguivgroup(,
  3847.         bguivarspace(40)||,
  3848.         bguicycle('EH_highlightcolor_',esc"r"Color$':','ColorList','P')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1)||,
  3849.         bguicycle('EH_highlighttype_',esc"r"Type$':','EH_highlighttypelist_','P')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1)||,
  3850.         bguicycle("EH_weeknumber_",esc"r"WeekNumber$':',"EH_weeknumberlist_",'P')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight,1)||,
  3851.         bguicycle('EH_weektype_',esc"r"WeekType$":",'EH_weektypelist_','P')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight, 1)||,
  3852.         bguicycle("EH_weekend_",esc"r"Weekend$":",'EH_weekendlist_','P')bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight,1)||,
  3853.         bguicheckbox("EH_holiday_",esc"r"Holiday$":",0)bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight,1)||,
  3854.         bguihgroup(,
  3855.           bguistring("EH_easter_",Easter$':',,4)bguilayout(LGO_FixMinHeight,1)||,
  3856.           bguivarspace(40),
  3857.         )||,
  3858.         bguihgroup(,
  3859.           bguibutton("EH_new_",AddEvent$)bguilayout(LGO_FixMinHeight,1)||,
  3860.           bguibutton("EH_delete_",DeleteEvent$)bguilayout(LGO_FixMinHeight,1),
  3861.         )||,
  3862.         bguihgroup(,
  3863.           bguibutton("EH_done_",Done$)bguilayout(LGO_FixMinHeight,1),
  3864.         ),
  3865.       ),
  3866.     ),
  3867.   ,"-1","-1")
  3868.  
  3869.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3870.   EH_winID=bguiwindow(EnterEventInfo$,EH_g,5,0,,AppScreen)
  3871.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  3872.  
  3873.   call bguiwintabcycleorder(EH_winID,obj.EH_event_||obj.EH_comment_)
  3874.   if EH_EntryCount == 0 then call EH_GhostGads
  3875.   else if EH_SelectMonth == 14 then do
  3876.     call EH_GhostGads
  3877.     call EH_SetGads
  3878.   end
  3879.   else do
  3880.     do EH_i = 1 to EH_Button
  3881.       EH_temp = EH_Button.EH_i
  3882.       if EH_Arg.EH_temp == 'dummy' then interpret "call bguiset(obj."EH_i"_,EH_winID, GA_Disabled, 1)"
  3883.     end
  3884.   end
  3885.  
  3886.   call bguiset(obj.changemonth_,EH_winID,CYC_Active,EH_SelectMonth - 1)
  3887.   /**/
  3888.  
  3889.   /***//*** GUI Action Loop ***/
  3890.   EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  3891.   call EH_SetRequester
  3892.   if EH_EntryCount > 0 then EH_DayShowing = EH_EventDay.EH_CurrentEntry
  3893.   if bguiwinopen(EH_winID)=0 then bguierror(12)
  3894.  
  3895.   call CloseBusy(Req)
  3896.  
  3897.   id=0
  3898.   EH_Done = 0
  3899.   do until EH_Done ~= 0
  3900.     call bguiwinwaitevent(EH_winID,"ID")
  3901.     select
  3902.     /***//*** Close ***/
  3903.       when (id == id.EH_cancel_) | (id == id.winclose) then do
  3904.         call bguiwinclose(EH_winID)
  3905.         EH_Done = 1
  3906.       end
  3907.     /**/
  3908.  
  3909.     /***//*** Done ***/
  3910.       when id == id.EH_done_ then do
  3911.         call EH_ReadSettings
  3912.         call EH_SaveHighlightData
  3913.         call bguiwinclose(EH_winID)
  3914.         EH_Done = 1
  3915.       end
  3916.     /**/
  3917.  
  3918.     /***//*** EH_EventGad ***/
  3919.       when id == id.EH_event_ then EH_Event.EH_CurrentEntry = bguiget(obj.EH_event_, STRINGA_TextVal)
  3920.     /**/
  3921.  
  3922.     /***//*** EH_PrevGad ***/
  3923.       when id == id.EH_prev_ then do
  3924.         call EH_ReadSettings
  3925.         EH_CurrentPointer = EH_CurrentPointer - 1
  3926.         EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  3927.         call EH_SetRequester
  3928.         EH_DayShowing = EH_EventDay.EH_CurrentEntry
  3929.       end
  3930.     /**/
  3931.  
  3932.     /***//*** EH_NextGad ***/
  3933.       when id == id.EH_next_ then do
  3934.         call EH_ReadSettings
  3935.         EH_CurrentPointer = EH_CurrentPointer + 1
  3936.         EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  3937.         call EH_SetRequester
  3938.         EH_DayShowing = EH_EventDay.EH_CurrentEntry
  3939.       end
  3940.     /**/
  3941.  
  3942.     /***//*** EH_EventImageGad ***/
  3943.       when id == id.EH_eventimage_ then do
  3944.         EH_Dir = CheckDir(ScriptDir'Images/')
  3945.         if EH_Dir == '' then EH_Dir = ScriptDir
  3946.         EH_DataFile = bguifilereq(EH_Dir, SelectImage$, EH_winID)
  3947.         if (EH_DataFile ~= '') & (exists(EH_DataFile) == 1) then call bguiset(obj.EH_event_, EH_winID, STRINGA_TextVal,EH_DataFile)
  3948.         else do
  3949.           if EH_DataFile ~= '' then call bguireq(EH_DataFile' 'CantFind$'...','*'OK$,'FWCalendar 'Notice$,EH_winID)
  3950.           EH_DataFile = ''
  3951.         end
  3952.       end
  3953.     /**/
  3954.  
  3955.     /***//*** EH_ChangeMontGad ***/
  3956.       when id == id.changemonth_ then do
  3957.         call EH_ReadSettings
  3958.         call EH_SaveHighlightData
  3959.         call bguiwinclose(EH_winID)
  3960.         EH_SelectMonth = bguiget(obj.changemonth_,CYC_Active) + 1
  3961.         call bguiwinclose(EH_winID)
  3962.         EH_Done = 2
  3963.       end
  3964.     /**/
  3965.  
  3966.     /***//*** EH_HighlightTypeGad ***/
  3967.       when id == id.EH_highlighttype_ then do
  3968.         EH_HighlightType = bguiget(obj.EH_highlighttype_,CYC_Active)
  3969.         EH_HighlightType.CurrentEntry = EH_HighlightTypeCyc.EH_HighlightType
  3970.         select
  3971.           when EH_HighlightType.CurrentEntry == 'Fixed' then call EH_SetFixed
  3972.           when EH_HighlightType.CurrentEntry == 'Float' then do
  3973.             call EH_SetFloat
  3974.             call EH_CheckWeekNumber
  3975.           end
  3976.           when EH_HighlightType.CurrentEntry == 'BiOrWeekly' then do
  3977.             call EH_SetBiOrWeekly
  3978.             call EH_CheckWeekType
  3979.           end
  3980.         end
  3981.       end
  3982.     /**/
  3983.  
  3984.     /***//*** EH_WeekNumberGad ***/
  3985.       when id == id.EH_weeknumber_ then do
  3986.         if EH_EventDay.EH_CurrentEntry > 0 then do
  3987.           EH_GadgetID = EH_ButtonID.EH_DayShowing
  3988.           interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 0)"
  3989.           EH_EventDay = EH_EventDay.EH_CurrentEntry
  3990.           EH_Weeknumber.EH_CurrentEntry = bguiget(obj.EH_weeknumber_,CYC_Active)
  3991.  
  3992.           do until EH_EventDay < 1
  3993.             EH_EventDay = EH_EventDay - 7
  3994.           end
  3995.           do EH_i = 0 to EH_Weeknumber.EH_CurrentEntry
  3996.             EH_EventDay = EH_EventDay + 7
  3997.           end
  3998.           if EH_EventDay > MonthLength.EH_ShortMonth then EH_EventDay = EH_EventDay - 7
  3999.  
  4000.           EH_GadgetID = EH_ButtonID.EH_EventDay
  4001.           interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 1)"
  4002.           EH_EventDay.EH_CurrentEntry = EH_EventDay
  4003.           EH_DayShowing = EH_EventDay
  4004.         end
  4005.       end
  4006.     /**/
  4007.  
  4008.     /***//*** EH_WeekTypeGad ***/
  4009.       when id == id.EH_weektype_ then do
  4010.         if EH_EventDay.EH_CurrentEntry > 0 then do
  4011.           EH_GadgetID = EH_ButtonID.EH_DayShowing
  4012.           interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 0)"
  4013.           EH_EventDay = EH_EventDay.EH_CurrentEntry
  4014.           EH_TempWeek = bguiget(obj.EH_weektype_,CYC_Active)
  4015.           if (EH_TempWeek ~= 0) & (EH_Week ~= EH_TempWeek) then do
  4016.             if EH_EventDay - 7 < 1 then EH_EventDay = EH_EventDay + 7
  4017.             else EH_EventDay = EH_EventDay - 7
  4018.           end
  4019.           EH_GadgetID = EH_ButtonID.EH_EventDay
  4020.           interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 1)"
  4021.           EH_EventDay.EH_CurrentEntry = EH_EventDay
  4022.           EH_DayShowing = EH_EventDay
  4023.           EH_Week = EH_TempWeek
  4024.         end
  4025.       end
  4026.     /**/
  4027.  
  4028.     /***//*** EH_NewGad ***/
  4029.       when id == id.EH_new_ then do
  4030.         call EH_ReadSettings
  4031.         if EH_DayShowing ~= 0 then do
  4032.           EH_GadgetID = EH_ButtonID.EH_DayShowing
  4033.           interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 0)"
  4034.         end
  4035.         EH_EntryCount = EH_EntryCount + 1
  4036.         EH_CurrentPointer = EH_EntryCount
  4037.         EH_HighEntry = EH_HighEntry + 1
  4038.         EH_Pointer.EH_CurrentPointer = EH_HighEntry
  4039.         EH_CurrentEntry = EH_HighEntry
  4040.         call EH_CreateEntry
  4041.         call EH_SetGads
  4042.         call EH_SetRequester
  4043.       end
  4044.     /**/
  4045.  
  4046.     /***//*** EH_DeleteGad ***/
  4047.       when id == id.EH_delete_ then do
  4048.         call EH_ReadSettings
  4049.         if EH_EntryCount == 1 then do
  4050.           EH_CurrentEntry   = 0
  4051.           EH_CurrentPointer = 0
  4052.           EH_EntryCount     = 0
  4053.         end
  4054.         else do
  4055.           do EH_i = EH_CurrentPointer to EH_EntryCount - 1
  4056.             EH_NextPointer = EH_i + 1
  4057.             EH_Pointer.EH_i = EH_Pointer.EH_NextPointer
  4058.           end
  4059.           EH_EntryCount = EH_EntryCount - 1
  4060.           EH_CurrentPointer = min(EH_CurrentPointer, EH_EntryCount)
  4061.           EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  4062.         end
  4063.         call EH_SetRequester
  4064.         EH_DayShowing = EH_EventDay.EH_CurrentEntry
  4065.       end
  4066.     /**/
  4067.  
  4068.     /***//*** EH_DateButtons ***/
  4069.       when (datatype(EH_Arg.id) == 'NUM') | (EH_Arg.id == 'LD') then do
  4070.         if EH_Arg.id == EH_DayShowing then do
  4071.           /* Re-set current date button */
  4072.           EH_GadgetID = EH_ButtonID.EH_DayShowing
  4073.           interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 1)"
  4074.         end
  4075.         else do
  4076.           /* Clear previous date button if necessary */
  4077.           if EH_DayShowing ~= 0 then do
  4078.             EH_GadgetID = EH_ButtonID.EH_DayShowing
  4079.             interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 0)"
  4080.           end
  4081.           /* Set current date button */
  4082.           EH_DayShowing = EH_Arg.id
  4083.           EH_GadgetID = EH_ButtonID.EH_DayShowing
  4084.           interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 1)"
  4085.           EH_EventDay.EH_CurrentEntry = EH_Arg.id
  4086.  
  4087.           /* Check for impacts of change */
  4088.           if EH_HighlightType.CurrentEntry == 'Float' then call EH_CheckWeekNumber
  4089.           else if EH_HighlightType.CurrentEntry == 'BiOrWeekly' then call EH_CheckWeekType
  4090.         end
  4091.       end
  4092.     /**/
  4093.  
  4094.       otherwise nop
  4095.     end
  4096.   end
  4097.   return EH_Done
  4098.   /**/
  4099.  
  4100. /***//*** EH_CheckWeekNumber  *********/
  4101. EH_CheckWeekNumber:
  4102.   EH_TempDay = EH_EventDay.EH_CurrentEntry
  4103.   EH_Weeknumber.EH_CurrentEntry = 0
  4104.  
  4105.   do until EH_TempDay < 0
  4106.     EH_TempDay = EH_TempDay - 7
  4107.     if EH_TempDay > 0 then EH_Weeknumber.EH_CurrentEntry = EH_Weeknumber.EH_CurrentEntry + 1
  4108.   end
  4109.   call bguiset(obj.EH_weeknumber_, EH_winID, CYC_Active, EH_Weeknumber.EH_CurrentEntry)
  4110.  
  4111.   return
  4112. /**/
  4113.  
  4114. /***//*** EH_CheckWeekType  *********/
  4115. EH_CheckWeekType:
  4116.   interpret 'EH_StartYear = Day.'DateInfo('W', EH_Year'0101', 'S')
  4117.   EH_YearOffset = 7 - EH_StartYear
  4118.   if EH_YearOffset == 7 then EH_YearOffset = 0
  4119.   EH_Week = 2 - (trunc((right(DateInfo('J', EH_Year''EH_Month''right(EH_EventDay.EH_CurrentEntry, 2, '0'), 'S'), 3) - EH_YearOffset - 1)/7 + 1))//2
  4120.   call bguiset(obj.EH_weektype_, EH_winID, CYC_Active, EH_Week)
  4121.   return
  4122. /**/
  4123.  
  4124. /***//*** EH_CreateEntry  *********/
  4125. EH_CreateEntry:
  4126.   EH_Event.EH_CurrentEntry    = ''
  4127.   EH_Comment.EH_CurrentEntry  = ''
  4128.   EH_EventDay.EH_CurrentEntry = 1
  4129.   EH_Holiday.EH_CurrentEntry  = 0
  4130.   EH_Color.EH_CurrentEntry    = ColorList.COUNT
  4131.  
  4132.   if EH_SelectMonth < 14 then do
  4133.     EH_HighlightType.EH_CurrentEntry = 'Fixed'
  4134.     EH_Keyword.EH_CurrentEntry       = 'Highlight'
  4135.     EH_Weekend.EH_CurrentEntry       = 'OK'
  4136.     EH_DayShowing                    = 1
  4137.   end
  4138.  
  4139.   return
  4140. /**/
  4141.  
  4142. /***//*** EH_GhostGads  *********/
  4143. EH_GhostGads:
  4144.   do EH_i = 1 to EH_Button
  4145.     interpret "call bguiset(obj."EH_i"_,EH_winID, GA_Disabled, 1, GA_Selected, 0)"
  4146.   end
  4147.   call bguiset(obj.EH_event_,EH_winID,GA_Disabled, 1)
  4148.   call bguiset(obj.EH_event_, EH_winID, STRINGA_TextVal,'')
  4149.   call bguiset(obj.EH_comment_,EH_winID,GA_Disabled, 1)
  4150.   call bguiset(obj.EH_comment_, EH_winID, STRINGA_TextVal,'')
  4151.   call bguiset(obj.EH_eventimage_,EH_winID,GA_Disabled, 1)
  4152.   call bguiset(obj.EH_highlightcolor_,EH_winID,GA_Disabled, 1)
  4153.   call bguiset(obj.EH_highlighttype_,EH_winID,GA_Disabled, 1)
  4154.   call bguiset(obj.EH_weeknumber_,EH_winID,GA_Disabled, 1)
  4155.   call bguiset(obj.EH_weektype_,EH_winID,GA_Disabled, 1)
  4156.   call bguiset(obj.EH_weekend_,EH_winID,GA_Disabled, 1)
  4157.   call bguiset(obj.EH_holiday_,EH_winID,GA_Disabled, 1)
  4158.   call bguiset(obj.EH_easter_,EH_winID, GA_Disabled, 1)
  4159.   call bguiset(obj.EH_easter_, EH_winID, STRINGA_TextVal,'')
  4160.   call bguiset(obj.EH_delete_,EH_winID, GA_Disabled, 1)
  4161.   return
  4162. /**/
  4163.  
  4164. /***//*** EH_ReadSettings  *********/
  4165. EH_ReadSettings:
  4166.   EH_Event.EH_CurrentEntry = bguiget(obj.EH_event_, STRINGA_TextVal)
  4167.   EH_Comment.EH_CurrentEntry = bguiget(obj.EH_comment_, STRINGA_TextVal)
  4168.   EH_Color.EH_CurrentEntry = bguiget(obj.EH_highlightcolor_, CYC_Active)
  4169.  
  4170.   parse var EH_Event.EH_CurrentEntry EH_Image','EH_X','EH_Y
  4171.   if exists(EH_Image) then EH_Image = 1
  4172.   else EH_Image = 0
  4173.   if EH_SelectMonth < 14 then do
  4174.     EH_HighlightType = bguiget(obj.EH_highlighttype_,CYC_Active)
  4175.     interpret 'EH_HighlightType.EH_CurrentEntry = EH_HighlightTypeCyc.'EH_HighlightType
  4176.     interpret 'EH_Keyword.EH_CurrentEntry = EH_KeywordCode.'EH_HighlightType''EH_Image
  4177.     EH_Weeknumber.EH_CurrentEntry = bguiget(obj.EH_weeknumber_,CYC_Active)
  4178.     interpret 'EH_WeekType.EH_CurrentEntry = EH_WeekTypeCyc.'bguiget(obj.EH_weektype_,CYC_Active)
  4179.     interpret 'EH_Weekend.EH_CurrentEntry = EH_WeekendCyc.'bguiget(obj.EH_weekend_,CYC_Active)
  4180.   end
  4181.   else EH_EventDay.EH_CurrentEntry = bguiget(obj.EH_easter_, STRINGA_TextVal)
  4182.  
  4183.   EH_Holiday.EH_CurrentEntry = bguiget(obj.EH_holiday_, GA_Selected)
  4184.   return
  4185. /**/
  4186.  
  4187. /***//*** EH_SaveHighlightData  *********/
  4188. EH_SaveHighlightData:
  4189.   do EH_i = 1 to EH_EntryCount
  4190.     EH_CurrentPointer = EH_i
  4191.     EH_CurrentEntry   = EH_Pointer.EH_CurrentPointer
  4192.     EH_EventDay = EH_EventDay.EH_CurrentEntry
  4193.  
  4194.     interpret 'EH_Color = ColorList.'EH_Color.EH_CurrentEntry
  4195.     if EH_EventDay == 'LD' then EH_EventDay = 32
  4196.     if pos('"', EH_Event.EH_CurrentEntry) == 0 then EH_QuoteChar = '"'
  4197.     else QuoteChar = "'"
  4198.     if EH_Holiday.EH_CurrentEntry == 128 then EH_Event.EH_CurrentEntry = EH_Event.EH_CurrentEntry'#'
  4199.     if EH_Weekend.EH_CurrentEntry ~= 'OK' then EH_EventDay = EH_EventDay''EH_Weekend.EH_CurrentEntry
  4200.     if (upper(EH_Keyword.EH_CurrentEntry) == 'HIGHLIGHT') | (upper(EH_Keyword.EH_CurrentEntry) == 'IMAGE') then do
  4201.       EH_DataLine = EH_SelectMonth''EH_Keyword.EH_CurrentEntry'.'EH_SelectMonth - 0'.'EH_EventDay' =',
  4202.                     EH_QuoteChar''EH_Event.EH_CurrentEntry''EH_QuoteChar
  4203.       if upper(EH_Keyword.EH_CurrentEntry) == 'HIGHLIGHT' then EH_DataLine = EH_DataLine ' ,'EH_QuoteChar''EH_Color''EH_QuoteChar
  4204.     end
  4205.     else if (upper(EH_Keyword.EH_CurrentEntry) == 'CALCULATEDATE') | (upper(EH_Keyword.EH_CurrentEntry) == 'CALCULATEIMAGE') then do
  4206.       EH_DayOfWeek = DateInfo('W', EH_Year''EH_Month''right(EH_EventDay.EH_CurrentEntry, 2, '0'), 'S')
  4207.  
  4208.       if EH_HighlightType.EH_CurrentEntry == 'Float' then do
  4209.         interpret 'EH_DayNumber = Day.'EH_DayOfWeek
  4210.         if EH_Weeknumber.EH_CurrentEntry < 4 then do
  4211.           EH_DayNumber = EH_DayNumber + 1
  4212.           if EH_DayNumber == 7 then EH_DayNumber = 0
  4213.           interpret 'EH_DayOfWeek = Day.'EH_DayNumber
  4214.           EH_EventDay = 7 * (EH_Weeknumber.EH_CurrentEntry + 1)
  4215.         end
  4216.         else do
  4217.           EH_EventDay = Monthlength.EH_ShortMonth
  4218.           EH_TempDay = Monthlength.EH_ShortMonth - 29
  4219.           EH_DayNumber = EH_DayNumber - EH_TempDay
  4220.           if EH_DayNumber < 0 then EH_DayNumber = EH_DayNumber + 7
  4221.           else if EH_DayNumber > 6 then EH_DayNumber = EH_DayNumber - 7
  4222.           interpret 'EH_DayOfWeek = Day.'EH_DayNumber
  4223.         end
  4224.       end
  4225.       else EH_EventDay = "'"EH_WeekType.EH_CurrentEntry"'"
  4226.  
  4227.       EH_DataLine = EH_SelectMonth''EH_Keyword.EH_CurrentEntry'('EH_SelectMonth - 0',"'EH_DayOfWeek'",'EH_EventDay',',
  4228.                     EH_QuoteChar''EH_Event.EH_CurrentEntry''EH_QuoteChar
  4229.       if upper(EH_Keyword.EH_CurrentEntry) == 'CALCULATEDATE' then EH_DataLine = EH_DataLine ' ,'EH_QuoteChar''EH_Color''EH_QuoteChar
  4230.       EH_DataLine = EH_DataLine')'
  4231.     end
  4232.     else if EH_SelectMonth == 14 then do
  4233.       EH_DataLine = 'CalculateEDate('EH_EventDay.EH_CurrentEntry',',
  4234.                     EH_QuoteChar''EH_Event.EH_CurrentEntry''EH_QuoteChar',',
  4235.                     EH_QuoteChar''EH_Color''EH_QuoteChar')'
  4236.     end
  4237.     if EH_Comment.EH_CurrentEntry ~= '' then EH_DataLine = EH_DataLine'  /* 'EH_Comment.EH_CurrentEntry' */'
  4238.     HighlightData.EH_SelectMonth.EH_i = EH_DataLine
  4239.   end
  4240.   MonthCount.EH_SelectMonth = EH_EntryCount
  4241.   return
  4242. /**/
  4243.  
  4244. /***//*** EH_SetBiOrWeekly  *********/
  4245. EH_SetBiOrWeekly:
  4246.   EH_GadgetID = EH_ButtonID.LD
  4247.   interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Disabled, 1)"
  4248.   if EH_EventDay.EH_CurrentEntry == 'LD' then do
  4249.     interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 0)"
  4250.     EH_EventDay.EH_CurrentEntry = 1
  4251.     EH_GadgetID = EH_ButtonID.1
  4252.     interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 1)"
  4253.     EH_DayShowing = 1
  4254.   end
  4255.   call bguiset(obj.EH_weeknumber_,EH_winID,GA_Disabled, 1)
  4256.   call bguiset(obj.EH_weektype_,EH_winID,GA_Disabled, 0)
  4257.   call bguiset(obj.EH_weekend_,EH_winID,GA_Disabled, 1)
  4258.   call bguiset(obj.EH_easter_,EH_winID,GA_Disabled, 1)
  4259.   return
  4260. /**/
  4261.  
  4262. /***//*** EH_SetFixed  *********/
  4263. EH_SetFixed:
  4264.   EH_GadgetID = EH_ButtonID.LD
  4265.   interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Disabled, 0)"
  4266.   call bguiset(obj.EH_weeknumber_,EH_winID,GA_Disabled, 1)
  4267.   call bguiset(obj.EH_weektype_,EH_winID,GA_Disabled, 1)
  4268.   call bguiset(obj.EH_weekend_,EH_winID,GA_Disabled, 0)
  4269.   call bguiset(obj.EH_easter_,EH_winID,GA_Disabled, 1)
  4270.   return
  4271. /**/
  4272.  
  4273. /***//*** EH_SetFloat  *********/
  4274. EH_SetFloat:
  4275.   EH_GadgetID = EH_ButtonID.LD
  4276.   interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Disabled, 1)"
  4277.   if EH_EventDay.EH_CurrentEntry == 'LD' then do
  4278.     interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 0)"
  4279.     EH_EventDay.EH_CurrentEntry = 1
  4280.     EH_GadgetID = EH_ButtonID.1
  4281.     interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 1)"
  4282.     EH_DayShowing = 1
  4283.   end
  4284.   call bguiset(obj.EH_weeknumber_,EH_winID,GA_Disabled, 0)
  4285.   call bguiset(obj.EH_weektype_,EH_winID,GA_Disabled, 1)
  4286.   call bguiset(obj.EH_weekend_,EH_winID,GA_Disabled, 1)
  4287.   call bguiset(obj.EH_easter_,EH_winID,GA_Disabled, 1)
  4288.   return
  4289. /**/
  4290.  
  4291. /***//*** EH_SetGads  *********/
  4292. EH_SetGads:
  4293.   if EH_SelectMonth ~= 14 then do
  4294.     do EH_i = 1 to EH_Button
  4295.       EH_temp = EH_Button.EH_i
  4296.       if EH_Arg.EH_temp ~= 'dummy' then interpret "call bguiset(obj."EH_i"_,EH_winID, GA_Disabled, 0)"
  4297.     end
  4298.     call bguiset(obj.EH_highlighttype_,EH_winID,GA_Disabled, 0)
  4299.     call bguiset(obj.EH_weeknumber_,EH_winID,GA_Disabled, 0)
  4300.     call bguiset(obj.EH_weektype_,EH_winID,GA_Disabled, 0)
  4301.     call bguiset(obj.EH_weekend_,EH_winID,GA_Disabled, 0)
  4302.   end
  4303.   else call bguiset(obj.EH_easter_,EH_winID, GA_Disabled, 0)
  4304.  
  4305.   call bguiset(obj.EH_event_,EH_winID,GA_Disabled, 0)
  4306.   call bguiset(obj.EH_comment_,EH_winID,GA_Disabled, 0)
  4307.   call bguiset(obj.EH_highlightcolor_,EH_winID,GA_Disabled, 0)
  4308.   call bguiset(obj.EH_eventimage_,EH_winID,GA_Disabled, 0)
  4309.   call bguiset(obj.EH_holiday_,EH_winID,GA_Disabled, 0)
  4310.   call bguiset(obj.EH_delete_,EH_winID, GA_Disabled, 0)
  4311.   return
  4312. /**/
  4313.  
  4314. /***//*** EH_SetRequester  *********/
  4315. call EH_SetRequester:
  4316.   /* Set 'Prev' & 'Next' gads */
  4317.   if EH_CurrentPointer < 2 then call bguiset(obj.EH_prev_,EH_winID,GA_Disabled, 1)
  4318.   else call bguiset(obj.EH_prev_,EH_winID,GA_Disabled, 0)
  4319.   if EH_CurrentPointer == EH_EntryCount then call bguiset(obj.EH_next_,EH_winID,GA_Disabled, 1)
  4320.   else call bguiset(obj.EH_next_,EH_winID,GA_Disabled, 0)
  4321.  
  4322.   if EH_EntryCount > 0 then do
  4323.     if EH_SelectMonth < 14 then do
  4324.       /* De-select existing date button */
  4325.       if EH_DayShowing ~= 0 then do
  4326.         EH_GadgetID = EH_ButtonID.EH_DayShowing
  4327.         interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 0)"
  4328.       end
  4329.       /* Select current date button */
  4330.       EH_EventDay = EH_EventDay.EH_CurrentEntry
  4331.       EH_GadgetID = EH_ButtonID.EH_EventDay
  4332.       EH_HighlightType = EH_HighlightType.EH_CurrentEntry
  4333.       interpret "call bguiset(obj."EH_GadgetID"_,EH_winID, GA_Selected, 1)"
  4334.  
  4335.       interpret 'call bguiset(obj.EH_highlighttype_,EH_winID,CYC_Active,EH_HighlightTypeCyc.'EH_HighlightType')'
  4336.       interpret 'call EH_Set'EH_HighlightType
  4337.       interpret 'call bguiset(obj.EH_weekend_,EH_winID,CYC_Active,EH_WeekendCyc.'EH_Weekend.EH_CurrentEntry')'
  4338.       call bguiset(obj.EH_holiday_,EH_winID,GA_Selected,EH_Holiday.EH_CurrentEntry)
  4339.       if EH_HighlightType == 'Float' then call EH_CheckWeekNumber
  4340.       else if EH_HighlightType == 'BiOrWeekly' then call EH_CheckWeekType
  4341.     end
  4342.     else call bguiset(obj.EH_easter_, EH_winID, STRINGA_TextVal,EH_EventDay.EH_CurrentEntry)
  4343.  
  4344.     /* Set event & comment */
  4345.     call bguiset(obj.EH_event_, EH_winID, STRINGA_TextVal,EH_Event.EH_CurrentEntry)
  4346.     call bguiset(obj.EH_comment_, EH_winID, STRINGA_TextVal,EH_Comment.EH_CurrentEntry)
  4347.     call bguiset(obj.EH_highlightcolor_,EH_winID,CYC_Active,EH_Color.EH_CurrentEntry)
  4348.   end
  4349.   else call EH_GhostGads
  4350.  
  4351.   return
  4352. /**/
  4353.  
  4354. /**/
  4355.  
  4356. /***//*** EditHighlight_CA (EH) ***/
  4357. EditHighlight_CA:
  4358.   /***//*** Initialize Variables ***/
  4359.   Req = OpenBusy(PrepReq$, 6)
  4360.   EH_DayShowing = 0
  4361.  
  4362.   EH_WeekendCyc.0     = "OK"
  4363.   EH_WeekendCyc.1     = "P"
  4364.   EH_WeekendCyc.2     = "N"
  4365.   EH_WeekendCyc.OK    = 0
  4366.   EH_WeekendCyc.P     = 1
  4367.   EH_WeekendCyc.N     = 2
  4368.  
  4369.   EH_WeekTypeCyc.0    = "All"
  4370.   EH_WeekTypeCyc.1    = "Odd"
  4371.   EH_WeekTypeCyc.2    = "Even"
  4372.   EH_WeekTypeCyc.All  = 0
  4373.   EH_WeekTypeCyc.Odd  = 1
  4374.   EH_WeekTypeCyc.Even = 2
  4375.  
  4376.   EH_HighlightTypeCyc.Fixed      = 0
  4377.   EH_HighlightTypeCyc.Float      = 1
  4378.   EH_HighlightTypeCyc.BiOrWeekly = 2
  4379.   EH_HighlightTypeCyc.Easter     = 3
  4380.   EH_HighlightTypeCyc.0          = 'Fixed'
  4381.   EH_HighlightTypeCyc.1          = 'Float'
  4382.   EH_HighlightTypeCyc.2          = 'BiOrWeekly'
  4383.   EH_HighlightTypeCyc.3          = 'Easter'
  4384.  
  4385.   EH_KeywordCode.00 = 'Highlight'
  4386.   EH_KeywordCode.01 = 'Image'
  4387.   EH_KeywordCode.10 = 'CalculateDate'
  4388.   EH_KeywordCode.11 = 'CalculateImage'
  4389.   EH_KeywordCode.20 = 'CalculateDate'
  4390.   EH_KeywordCode.21 = 'CalculateImage'
  4391.  
  4392.   EH_Year = left(date('S'),4)
  4393.   interpret 'EH_StartYear = Day.'DateInfo('W', EH_Year'0101', 'S')
  4394.   EH_YearOffset = 7 - EH_StartYear
  4395.   if EH_YearOffset == 7 then EH_YearOffset = 0
  4396.  
  4397.   EH_SelectMonth = right(EH_SelectMonth, 2, '0')
  4398. /**/
  4399.  
  4400.   /***//*** GUI Description ***/
  4401.   if UpdateBusy(Req, 1) == -1 then call EH_CACleanup
  4402.   HighlightTypeList = '"'Fixed$'|'Floating$'|'BiOrWeekly$'"'
  4403.   WeekNumberList = '"'First$'|'Second$'|'Third$'|'Fourth$'|'Last$'"'
  4404.   WeekTypeList = '"'All$'|'Odd$'|'Even$'"'
  4405.   WeekendList = '"'OK2$'|'PreviousDay$'|'NextDay$'"'
  4406.   EH_MonthList = strip(MonthList, 'T', '"')'|'All$'|'Easter$'"'
  4407.  
  4408.   call open('EH',"awnpipe:SetupReq/xc")
  4409.   call ToPIPE('EH', '"'EnterEventInfo$'" m cg dg v db a so si cs sq sk h ps="'AppScreen'"')
  4410.  
  4411.   call ToPIPE('EH', 'layout v so si b=0')
  4412.     call ToPIPE('EH', 'layout b=0')
  4413.       call ToPIPE('EH', 'label gt="'Event$':" ua')
  4414.       call AssignID('EH_EventGad', ToPIPE('EH', 'string lj tc chl ref'))
  4415.       call AssignID('EH_ChooseEventGad', ToPIPE('EH', 'button ab=0 weiw=0 weih=0 ref'))
  4416.       call AssignID('EH_ListEventGad', ToPIPE('EH', 'chooser weiw=0 weih=0 ref'))
  4417.       call AssignID('EH_CycleEventGad', ToPIPE('EH', 'button weiw=0 gt=">" ref'))
  4418.     call ToPIPE('EH', 'le')
  4419.  
  4420.     call ToPIPE('EH', 'layout b=0')
  4421.       call ToPIPE('EH', 'label gt="'Comment$':" ua')
  4422.       call AssignID('EH_CommentGad', ToPIPE('EH', 'string lj tc chl ref'))
  4423.     call ToPIPE('EH', 'le')
  4424.   call ToPIPE('EH', 'le')
  4425.  
  4426.   call ToPIPE('EH', 'layout weiw=0 b=0')
  4427.     call ToPIPE('EH', 'layout weiw=0 so v')
  4428.       call ToPIPE('EH', 'layout so b=0')
  4429.         call ToPIPE('EH', 'space')
  4430.         call AssignID('EH_MonthGad', ToPIPE('EH', 'chooser pu weiw=5 maxn=14 cl='EH_Monthlist' ref'))
  4431.         call ToPIPE('EH', 'space')
  4432.       call ToPIPE('EH', 'le')
  4433.  
  4434.       call ToPIPE('EH', 'layout e b=0')
  4435.         call ToPIPE('EH', 'button ro b=0 gt="'left(Day.0, 1)'"')
  4436.         call ToPIPE('EH', 'button ro b=0 gt="'left(Day.1, 1)'"')
  4437.         call ToPIPE('EH', 'button ro b=0 gt="'left(Day.2, 1)'"')
  4438.         call ToPIPE('EH', 'button ro b=0 gt="'left(Day.3, 1)'"')
  4439.         call ToPIPE('EH', 'button ro b=0 gt="'left(Day.4, 1)'"')
  4440.         call ToPIPE('EH', 'button ro b=0 gt="'left(Day.5, 1)'"')
  4441.         call ToPIPE('EH', 'button ro b=0 gt="'left(Day.6, 1)'"')
  4442.       call ToPIPE('EH', 'le')
  4443.  
  4444.       if UpdateBusy(Req, 1) == -1 then call EH_CACleanup
  4445.       GadID.  = ''
  4446.       do EH_Week = 0 to 5
  4447.         call ToPIPE('EH', 'layout e b=0')
  4448.         do EH_WeekDay = 0 to 6
  4449.           EH_Posn = (EH_Week * 7) + EH_WeekDay
  4450.           call AssignID('GadID.'EH_Posn, ToPIPE('EH', 'button pb'))
  4451.         end
  4452.         call ToPIPE('EH', 'le')
  4453.       end
  4454.     call ToPIPE('EH', 'le')
  4455.  
  4456.     if UpdateBusy(Req, 1) == -1 then call EH_CACleanup
  4457.     call ToPIPE('EH', 'layout weiw=0 si so v')
  4458.       call ToPIPE('EH', 'layout weiw=0 si so b=0 v')
  4459.         call ToPIPE('EH', 'label weiw=0 ua gt="'Color$':"')
  4460.         call AssignID('EH_ColorGad', ToPIPE('EH', 'button chl weih=0 ref'))
  4461.         call ToPIPE('EH', 'label weiw=0 gt="'Type$':" ua')
  4462.         call AssignID('EH_HLTypeGad', ToPIPE('EH', 'chooser chl pu weiw=0 maxn=3 cl='HighlightTypeList' ref'))
  4463.         call ToPIPE('EH', 'label weiw=0 gt="'WeekNumber$':" ua')
  4464.         call AssignID('EH_WeekNumberGad', ToPIPE('EH', 'chooser chl pu weiw=0 maxn=5 cl='WeekNumberList' ref'))
  4465.         call ToPIPE('EH', 'label weiw=0 gt="'WeekType$':" ua')
  4466.         call AssignID('EH_WeekTypeGad', ToPIPE('EH', 'chooser chl pu weiw=0 maxn=3 cl='WeekTypeList' ref'))
  4467.         call ToPIPE('EH', 'label weiw=0 gt="'Weekend$':" ua')
  4468.         call AssignID('EH_WeekendGad', ToPIPE('EH', 'chooser chl pu weiw=0 maxn=3 cl='WeekendList' ref'))
  4469.         call ToPIPE('EH', 'label weiw=0 gt="'Holiday$':" ua')
  4470.         call AssignID('EH_HolidayGad', ToPIPE('EH', 'checkbox weiw=0 chl ref'))
  4471.         call ToPIPE('EH', 'label weiw=0 gt="'Easter$':" ua')
  4472.         call AssignID('EH_EasterGad', ToPIPE('EH', 'integer a tc minn=-366 maxn=366 weiw=0 lj chl ref'))
  4473.       call ToPIPE('EH', 'le')
  4474.       call ToPIPE('EH', 'layout v si e cj b=0')
  4475.         call ToPIPE('EH', 'layout si e weiw=0 b=0')
  4476.           call AssignID('EH_AddEventGad', ToPIPE('EH', 'button weiw=0 weih=0 gt="'AddEvent$'" ref'))
  4477.           call AssignID('EH_DeleteEventGad', ToPIPE('EH', 'button weiw=0 weih=0 gt="'DeleteEvent$'" ref'))
  4478.         call ToPIPE('EH', 'le')
  4479.         call AssignID('EH_DoneGad', ToPIPE('EH', 'button weih=0 weiw=0 gt="'Done$'" c ref'))
  4480.       call ToPIPE('EH', 'le')
  4481.     call ToPIPE('EH', 'le')
  4482.   call ToPIPE('EH', 'le')
  4483.  
  4484.   GetEHFileGad = ToPIPE('EH', 'getfile ua pat="#?"')
  4485.  
  4486.   GadText.EH_CycleEventGad.0 = '>'
  4487.   GadText.EH_CycleEventGad.1 = '<'
  4488. /**/
  4489.  
  4490.   /***//*** GUI Action Loop ***/
  4491.   call ToPIPE('EH', 'open')
  4492.  
  4493.   if UpdateBusy(Req, 1) == -1 then call EH_CACleanup
  4494.  
  4495.   call EH_CASetRequester
  4496.   call CloseBusy('ProgReq')
  4497.  
  4498.   EH_Done = 0
  4499.   do until eof('EH')
  4500.     call ToPIPE('EH', 'continue')
  4501.     EH_EventInfo = readln('EH')
  4502.     parse var EH_EventInfo EH_Event' 'EH_GadID' 'EH_GadInfo1
  4503.     select
  4504.     /***//*** Close ***/
  4505.       when EH_Event == 'close' then do
  4506.         if EH_GadID == EH_DoneGad then call EH_CASaveHighlightData
  4507.         EH_Done = 1
  4508.       end
  4509.     /**/
  4510.  
  4511.     /***//*** Help ***/
  4512.       when EH_Event == 'help' then do
  4513.         if EH_GadID ~= -1 then do
  4514.           OverGad = EH_GadID
  4515.           if (EH_GadID ~= ShiftedGad) & (ShiftedGad > 0) then do
  4516.             call ToPIPE('EH', 'id 'ShiftedGad' gt="'GadText.ShiftedGad.0'"')
  4517.             ShiftedGad = 0
  4518.           end
  4519.           if (ShiftDown == 1) & (symbol('GadText.OverGad.1') == 'VAR') then do
  4520.             call ToPIPE('EH', 'id 'OverGad' gt="'GadText.OverGad.1'"')
  4521.             ShiftedGad = OverGad
  4522.           end
  4523.         end
  4524.       end
  4525.     /**/
  4526.  
  4527.     /***//*** Qualifers ***/
  4528.       when EH_Event == 'qual' then do
  4529.         ShiftDown = (EH_GadID == 1)|(EH_GadID == 2)
  4530.         if (ShiftDown == 0) & (ShiftedGad > 0) then do
  4531.           call ToPIPE('EH', 'id 'ShiftedGad' gt="'GadText.OverGad.0'"')
  4532.           ShiftedGad = 0
  4533.         end
  4534.         if (ShiftDown == 1) & (symbol('GadText.OverGad.1') == 'VAR') then do
  4535.           call ToPIPE('EH', 'id 'OverGad' gt="'GadText.OverGad.1'"')
  4536.           ShiftedGad = OverGad
  4537.         end
  4538.       end
  4539.     /**/
  4540.  
  4541.     /***//*** Key event ***/
  4542.       when EH_Event == 'key' then do
  4543.         HelpGad = DSR_Help.OverGad
  4544.         interpret 'HelpText = Help$.'HelpGad
  4545.         if EH_Day.OverGad == 'LD' then HelpText = Help$.LD
  4546.         if (EH_GadID == 95) & (symbol('Help$.'HelpGad) == 'VAR') then
  4547.           call CASimpleReq(Help$, HelpText, HelpTime)
  4548.       end
  4549.     /**/
  4550.  
  4551.     /***//*** EH_EventGad ***/
  4552.       when EH_GadID == EH_EventGad then call EH_CAProcessEventGad(EH_GadInfo1)
  4553.     /**/
  4554.  
  4555.     /***//*** EH_ChooseEventGad ***/
  4556.       when EH_GadID == EH_ChooseEventGad then do
  4557.         address command 'assign >NIL: FWC: 'ScriptDir'Images/'
  4558.         if RC == 20 then EH_Dir = ScriptDir
  4559.         else do
  4560.           EH_Dir = ScriptDir'Images/'
  4561.           address command 'assign >NIL: FWC:'
  4562.         end
  4563.         EH_DataFile = CAGetFile('EH', GetEHFileGad, SelectImage$, EH_Dir)
  4564.         if EH_DataFile ~= '' then do
  4565.           if exists(EH_DataFile) then do
  4566.             EH_Event.EH_CurrentEntry = EH_DataFile
  4567.             EH_Image.EH_CurrentEntry = 1
  4568.             call ToPIPE('EH', 'id 'EH_EventGad' gt="'EH_DataFile'"')
  4569.           end
  4570.           else do
  4571.             call ToPIPE('EH', 'id 0 s=256')
  4572.             call CASimpleReq('FWCalendar 'Notice$, EH_DataFile' 'CantFind$'...')
  4573.             call ToPIPE('EH', 'id 0 s=512')
  4574.           end
  4575.         end
  4576.         call EH_CAUpdateEventList
  4577.       end
  4578.     /**/
  4579.  
  4580.     /***//*** EH_ListEventGad ***/
  4581.       when EH_GadID == EH_ListEventGad then do
  4582.         EH_Comment.EH_CurrentEntry = ReadCAGad('EH', EH_CommentGad)
  4583.         call EH_CAProcessEventGad(ReadCAGad('EH', EH_EventGad))
  4584.         EH_CurrentPointer = EH_GadInfo1 + 1
  4585.         EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  4586.         call EH_CASetEvent
  4587.       end
  4588.    /**/
  4589.  
  4590.     /***//*** EH_CycleEventGad ***/
  4591.       when EH_GadID == EH_CycleEventGad then do
  4592.         EH_Comment.EH_CurrentEntry = ReadCAGad('EH', EH_CommentGad)
  4593.         call EH_CAProcessEventGad(ReadCAGad('EH', EH_EventGad))
  4594.         if ShiftDown == 1 then do
  4595.           EH_CurrentPointer = EH_CurrentPointer - 1
  4596.           if EH_CurrentPointer == 0 then EH_CurrentPointer = EH_EntryCount
  4597.           EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  4598.         end
  4599.         else do
  4600.           EH_CurrentPointer = EH_CurrentPointer + 1
  4601.           if EH_CurrentPointer > EH_EntryCount then EH_CurrentPointer = 1
  4602.           EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  4603.         end
  4604.         call EH_CASetEvent
  4605.       end
  4606.     /**/
  4607.  
  4608.     /***//*** EH_CommentGad ***/
  4609.       when EH_GadID == EH_CommentGad then EH_Comment.EH_CurrentEntry = EH_GadInfo1
  4610.     /**/
  4611.  
  4612.     /***//*** EH_MonthGad ***/
  4613.       when EH_GadID == EH_MonthGad then do
  4614.         EH_Comment.EH_CurrentEntry = ReadCAGad('EH', EH_CommentGad)
  4615.         call EH_CAProcessEventGad(ReadCAGad('EH', EH_EventGad))
  4616.         call EH_CASaveHighlightData
  4617.         EH_SelectMonth = right(EH_GadInfo1 + 1, 2, '0')
  4618.         call EH_CASetRequester
  4619.       end
  4620.     /**/
  4621.  
  4622.     /***//*** EH_ColorGad ***/
  4623.       when EH_GadID == EH_ColorGad then do
  4624.         call ToPIPE('EH', 'id 0 s=256')
  4625.         EH_Color.EH_CurrentEntry = ReadBrowserList('ColorReq', 'ColorGad', 'ColorList')
  4626.         call ToPIPE('EH', 'id 'EH_ColorGad' gt="'EH_Color.EH_CurrentEntry'"')
  4627.         call ToPIPE('EH', 'id 0 s=512')
  4628.       end
  4629.     /**/
  4630.  
  4631.     /***//*** EH_HLTypeGad ***/
  4632.       when EH_GadID == EH_HLTypeGad then do
  4633.         EH_HighlightType.EH_CurrentEntry = EH_GadInfo1
  4634.         select
  4635.           when EH_HighlightTypeCyc.EH_GadInfo1 == 'Fixed' then call EH_CASetFixedGads
  4636.           when EH_HighlightTypeCyc.EH_GadInfo1 == 'Float' then do
  4637.             call EH_CASetFloatGads
  4638.             call EH_CACheckWeekNumber
  4639.           end
  4640.           when EH_HighlightTypeCyc.EH_GadInfo1 == 'BiOrWeekly' then do
  4641.             call EH_CASetBiOrWeeklyGads
  4642.             call EH_CACheckWeekType
  4643.           end
  4644.         end
  4645.       end
  4646.     /**/
  4647.  
  4648.     /***//*** EH_WeekNumberGad ***/
  4649.       when EH_GadID == EH_WeekNumberGad then do
  4650.         EH_Weeknumber.EH_CurrentEntry = EH_GadInfo1
  4651.         if EH_EventDay.EH_CurrentEntry > 0 then do
  4652.           call ToPIPE('EH', 'id 'EH_ButtonID.EH_DayShowing' s=0 ref')
  4653.           EH_EventDay = EH_EventDay.EH_CurrentEntry
  4654.  
  4655.           do until EH_EventDay < 1
  4656.             EH_EventDay = EH_EventDay - 7
  4657.           end
  4658.           do EH_i = 0 to EH_Weeknumber.EH_CurrentEntry
  4659.             EH_EventDay = EH_EventDay + 7
  4660.           end
  4661.           if EH_EventDay > MonthLength.EH_ShortMonth then EH_EventDay = EH_EventDay - 7
  4662.  
  4663.           call ToPIPE('EH', 'id 'EH_ButtonID.EH_EventDay' s=1')
  4664.           EH_EventDay.EH_CurrentEntry = EH_EventDay
  4665.           EH_DayShowing = EH_EventDay
  4666.         end
  4667.       end
  4668.     /**/
  4669.  
  4670.     /***//*** EH_WeekTypeGad ***/
  4671.       when EH_GadID == EH_WeekTypeGad then do
  4672.         EH_WeekType.EH_CurrentEntry = EH_GadInfo1
  4673.         if EH_EventDay.EH_CurrentEntry > 0 then do
  4674.           call ToPIPE('EH', 'id 'EH_ButtonID.EH_DayShowing' s=0 ref')
  4675.           EH_EventDay = EH_EventDay.EH_CurrentEntry
  4676.           if (EH_WeekType.EH_CurrentEntry ~= 0) & (EH_TempWeekType.EH_CurrentEntry ~= EH_WeekType.EH_CurrentEntry) then do
  4677.             if EH_EventDay - 7 < 1 then EH_EventDay = EH_EventDay + 7
  4678.             else EH_EventDay = EH_EventDay - 7
  4679.           end
  4680.           call ToPIPE('EH', 'id 'EH_ButtonID.EH_EventDay' s=1')
  4681.           EH_EventDay.EH_CurrentEntry = EH_EventDay
  4682.           EH_DayShowing = EH_EventDay
  4683.           EH_TempWeekType.EH_CurrentEntry = EH_WeekType.EH_CurrentEntry
  4684.         end
  4685.       end
  4686.     /**/
  4687.  
  4688.     /***//*** EH_WeekendGad ***/
  4689.       when EH_GadID == EH_WeekendGad then EH_Weekend.EH_CurrentEntry = EH_GadInfo1
  4690.     /**/
  4691.  
  4692.     /***//*** EH_HolidayGad ***/
  4693.       when EH_GadID == EH_HolidayGad then EH_Holiday.EH_CurrentEntry = EH_GadInfo1
  4694.     /**/
  4695.  
  4696.     /***//*** EH_EasterGad ***/
  4697.       when EH_GadID == EH_EasterGad then do
  4698.         EH_Easter.EH_CurrentEntry = EH_GadInfo1
  4699.         EH_EventDay.EH_CurrentEntry = EH_GadInfo1
  4700.         call EH_CASortAndFind(EH_CurrentEntry)
  4701.       end
  4702.     /**/
  4703.  
  4704.     /***//*** EH_AddEventGad ***/
  4705.       when EH_GadID == EH_AddEventGad then do
  4706.         EH_Comment.EH_CurrentEntry = ReadCAGad('EH', EH_CommentGad)
  4707.         call EH_CAProcessEventGad(ReadCAGad('EH', EH_EventGad))
  4708.         if EH_EntryCount == 0 then call EH_CASetMonthGads
  4709.         if EH_DayShowing ~= 0 then call ToPIPE('EH', 'id 'EH_ButtonID.EH_DayShowing' s=0 ref')
  4710.         EH_EntryCount = EH_EntryCount + 1
  4711.         EH_CurrentEntry = EH_EntryCount
  4712.  
  4713.         EH_Event.EH_CurrentEntry    = ''
  4714.         EH_Comment.EH_CurrentEntry  = ''
  4715.         EH_EventDay.EH_CurrentEntry = 1
  4716.         EH_Holiday.EH_CurrentEntry  = 0
  4717.         EH_Color.EH_CurrentEntry    = '<'Clear$'>'
  4718.  
  4719.         if EH_SelectMonth < 14 then do
  4720.           EH_HighlightType.EH_CurrentEntry = 0
  4721.           EH_Keyword.EH_CurrentEntry       = 'Highlight'
  4722.           EH_Weekend.EH_CurrentEntry       = 0
  4723.         end
  4724.  
  4725.         call EH_CASortAndFind(EH_CurrentEntry)
  4726.         call EH_CASetEvent
  4727.       end
  4728.     /**/
  4729.  
  4730.     /***//*** EH_DeleteEventGad ***/
  4731.       when EH_GadID == EH_DeleteEventGad then do
  4732.         if EH_EntryCount == 1 then do
  4733.           EH_CurrentEntry   = 0
  4734.           EH_CurrentPointer = 0
  4735.           EH_EntryCount     = 0
  4736.           call EH_CAGhostGads
  4737.         end
  4738.         else do
  4739.           SortFile = ''
  4740.           do EH_i = 1 to EH_EntryCount
  4741.             if EH_i ~= EH_CurrentEntry then SortFile = SortFile''right(EH_i, 3, "0")' 'EH_EventDay.EH_i||'0a'x
  4742.           end
  4743.           call writefile('pipe:FWC', strip(SortFile, 'B', '0a'x))
  4744.           address command 'sort pipe:FWC Pipe:FWC1 Colstart 5 numeric'
  4745.  
  4746.           if EH_CurrentPointer == EH_EntryCount then EH_CurrentPointer = EH_CurrentPointer - 1
  4747.           else EH_CurrentPointer = EH_CurrentPointer + 1
  4748.           EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  4749.  
  4750.           EH_EntryCount = EH_EntryCount - 1
  4751.           SortedFile = ReadFile('pipe:FWC1')
  4752.           call openv('SortedFile')
  4753.           do EH_i = 1 to EH_EntryCount
  4754.             EH_Pointer.EH_i = left(readvln('SortedFile'), 3) - 0
  4755.             if EH_Pointer.EH_i == EH_CurrentEntry then EH_CurrentPointer = EH_i
  4756.           end
  4757.           call closev('SortedFile')
  4758.           call EH_CAUpdateEventList
  4759.           call EH_CASetEvent
  4760.         end
  4761.         call EH_CASetPrevAndNext
  4762.       end
  4763.     /**/
  4764.  
  4765.     /***//*** Date gadgets ***/
  4766.       otherwise do
  4767.         if symbol('EH_Day.EH_GadID') == 'VAR' then do
  4768.           EH_EventDay.EH_CurrentEntry = EH_Day.EH_GadID
  4769.           if EH_EventDay.EH_CurrentEntry == EH_DayShowing then call ToPIPE('EH', 'id 'EH_ButtonID.EH_DayShowing' s=1')
  4770.           else do
  4771.             /* Clear previous date button if necessary */
  4772.             if EH_DayShowing ~= 0 then call ToPIPE('EH', 'id 'EH_ButtonID.EH_DayShowing' s=0 ref')
  4773.             /* Set current date button */
  4774.             EH_DayShowing = EH_EventDay.EH_CurrentEntry
  4775.             call ToPIPE('EH', 'id 'EH_ButtonID.EH_DayShowing' s=1')
  4776.             /* Check for impacts of change */
  4777.             if EH_HighlightType.EH_CurrentEntry == EH_HighlightTypeCyc.Float then call EH_CACheckWeekNumber
  4778.             else if EH_HighlightType.EH_CurrentEntry == EH_HighlightTypeCyc.BiOrWeekly then call EH_CACheckWeekType
  4779.             call EH_CASortAndFind(EH_CurrentEntry)
  4780.           end
  4781.         end
  4782.       end
  4783.     /**/
  4784.  
  4785.     end
  4786.     if EH_Done ~= 0 then leave
  4787.     if (EH_Event = 'gadget') & (ShiftDown = 1) & (symbol('GadText.EH_GadID.1') == 'VAR') then do
  4788.       ShiftedGad = EH_GadID
  4789.       OverGad = EH_GadID
  4790.       call ToPIPE('EH', 'id 'ShiftedGad' gt="'GadText.ShiftedGad.1'"')
  4791.     end
  4792.   end
  4793.  
  4794.   OverGad       = 0
  4795.   ShiftDown     = 0
  4796.   ShiftedGad    = 0
  4797.   call close('EH')
  4798.   return
  4799. /**/
  4800.  
  4801. /***//*** EH_CACheckWeekNumber ***/
  4802. EH_CACheckWeekNumber:
  4803.   EH_TempDay = EH_EventDay.EH_CurrentEntry
  4804.   EH_Weeknumber.EH_CurrentEntry = 0
  4805.  
  4806.   do until EH_TempDay < 0
  4807.     EH_TempDay = EH_TempDay - 7
  4808.     if EH_TempDay > 0 then EH_Weeknumber.EH_CurrentEntry = EH_Weeknumber.EH_CurrentEntry + 1
  4809.   end
  4810.   call ToPIPE('EH', 'id 'EH_WeekNumberGad' s='EH_Weeknumber.EH_CurrentEntry)
  4811.  
  4812.   return
  4813. /**/
  4814.  
  4815. /***//*** EH_CACheckWeekType ***/
  4816. EH_CACheckWeekType:
  4817.   interpret 'EH_StartYear = Day.'DateInfo('W', EH_Year'0101', 'S')
  4818.   EH_YearOffset = 7 - EH_StartYear
  4819.   if EH_YearOffset == 7 then EH_YearOffset = 0
  4820.   EH_Week = 2 - (trunc((right(DateInfo('J', EH_Year''EH_Month''right(EH_EventDay.EH_CurrentEntry, 2, '0'), 'S'), 3) - EH_YearOffset - 1)/7 + 1))//2
  4821.   call ToPIPE('EH', 'id 'EH_WeekTypeGad' s='EH_Week)
  4822.   return
  4823. /**/
  4824.  
  4825. /***//*** EH_CACleanup ***/
  4826. EH_CACleanup:
  4827.   call CloseBusy('ProgReq')
  4828.   call close('EH')
  4829.   return
  4830. /**/
  4831.  
  4832. /***//*** EH_CAGhostGads ***/
  4833. EH_CAGhostGads:
  4834.   do EH_Posn = 0 to 41
  4835.     call ToPIPE('EH', 'id 'GadID.EH_Posn' s=0 dis=1')
  4836.   end
  4837.   call ToPIPE('EH', 'id 'EH_EventGad' gt="" dis=1 ref')
  4838.   call ToPIPE('EH', 'id 'EH_ChooseEventGad' dis=1 ref')
  4839.   call ToPIPE('EH', 'id 'EH_ListEventGad' dis=1')
  4840.   call ToPIPE('EH', 'id 'EH_CycleEventGad' dis=1')
  4841.   call ToPIPE('EH', 'id 'EH_CommentGad' gt="" dis=1')
  4842.   call ToPIPE('EH', 'id 'EH_ColorGad' dis=1')
  4843.   call ToPIPE('EH', 'id 'EH_HLTypeGad' dis=1')
  4844.   call ToPIPE('EH', 'id 'EH_WeekNumberGad' dis=1')
  4845.   call ToPIPE('EH', 'id 'EH_WeekTypeGad' dis=1')
  4846.   call ToPIPE('EH', 'id 'EH_WeekendGad' dis=1')
  4847.   call ToPIPE('EH', 'id 'EH_HolidayGad' dis=1 ref')
  4848.   call ToPIPE('EH', 'id 'EH_EasterGad' dis=1 ref')
  4849.   call ToPIPE('EH', 'id 'EH_DeleteEventGad' dis=1')
  4850.   return
  4851. /**/
  4852.  
  4853. /***//*** EH_CAProcessEventGad ***/
  4854. EH_CAProcessEventGad:
  4855.   parse arg Value
  4856.   EH_Event.EH_CurrentEntry = Value
  4857.   parse var EH_Event.EH_CurrentEntry EH_Image','EH_X.EH_CurrentEntry','EH_Y.EH_CurrentEntry
  4858.   if exists(EH_Image) then EH_Image.EH_CurrentEntry = 1
  4859.   else EH_Image.EH_CurrentEntry = 0
  4860.   call EH_CAUpdateEventList
  4861.  
  4862.   return
  4863. /**/
  4864.  
  4865. /***//*** EH_CAReadData ***/
  4866. EH_CAReadData:
  4867.   EH_EntryCount = 0
  4868.   OverGad       = 0
  4869.   ShiftDown     = 0
  4870.   ShiftedGad    = 0
  4871.  
  4872.   EH_MonthCount = MonthCount.EH_SelectMonth
  4873.   if EH_MonthCount > 0 then do
  4874.     do EH_j = 1 to EH_MonthCount
  4875.       EH_EntryCount = EH_EntryCount + 1
  4876.       if EH_SelectMonth < 14 then CurrentData.EH_SelectMonth.EH_j = substr(HighlightData.EH_SelectMonth.EH_j, 3)
  4877.       else CurrentData.EH_SelectMonth.EH_j = HighlightData.EH_SelectMonth.EH_j
  4878.       if symbol('CurrentData.EH_SelectMonth.EH_j') == 'VAR' then do
  4879.         EH_HighlightData = strip(CurrentData.EH_SelectMonth.EH_j)
  4880.         if right(EH_HighlightData, 2) == '*/' then do
  4881.           EH_StartComment = lastpos('/*', EH_HighlightData)
  4882.           EH_Comment.EH_EntryCount = strip(substr(EH_HighlightData, EH_StartComment), 'B', ' /*')
  4883.           EH_HighlightData = strip(left(EH_HighlightData, EH_StartComment - 1))
  4884.         end
  4885.         else EH_Comment.EH_EntryCount = ''
  4886.  
  4887.         EH_Keyword = word(EH_HighlightData, 1)
  4888.         EH_FirstDot = pos('.', EH_Keyword)
  4889.         EH_FirstParen = pos('(', EH_Keyword)
  4890.         if EH_FirstDot == 0 then EH_EndOfKeyword = EH_FirstParen
  4891.         else if EH_FirstParen == 0 then EH_EndOfKeyword = EH_FirstDot
  4892.         else EH_EndOfKeyword = min(pos('.', EH_Keyword), pos('(', EH_Keyword))
  4893.         EH_Keyword.EH_EntryCount = left(EH_Keyword, EH_EndOfKeyword - 1)
  4894.         if pos('IMAGE', upper(EH_Keyword.EH_EntryCount)) ~= 0 then EH_Image.EH_EntryCount = 1
  4895.         else EH_Image.EH_EntryCount = 0
  4896.  
  4897.         if (upper(EH_Keyword.EH_EntryCount) == 'HIGHLIGHT') | (upper(EH_Keyword.EH_EntryCount) == 'IMAGE') then do
  4898.           EH_HighlightType.EH_EntryCount = EH_HighlightTypeCyc.Fixed
  4899.           EH_EventDay.EH_EntryCount = substr(EH_Keyword, lastpos('.', EH_Keyword) + 1)
  4900.           EH_Event.EH_EntryCount = substr(EH_HighlightData, pos('=', EH_HighlightData) + 1)
  4901.           parse var EH_Event.EH_EntryCount EH_Event.EH_EntryCount','EH_Color.EH_EntryCount
  4902.           if upper(EH_Keyword.EH_EntryCount) == 'IMAGE' then do
  4903.             if (pos(':', EH_Event.EH_EntryCount) == 0) & (pos('/', EH_Event.EH_EntryCount) == 0) then
  4904.               EH_Event.EH_EntryCount = ScriptDir'Images/'strip(EH_Event.EH_EntryCount, 'B', ' "'||"'")
  4905.           end
  4906.         end
  4907.         else do
  4908.           EH_HighlightData = strip(substr(EH_HighlightData, EH_EndOfKeyword + 1), 'B', ')')
  4909.           if EH_SelectMonth == 14 then do
  4910.             parse var EH_HighlightData EH_EventDay.EH_EntryCount','EH_Event.EH_EntryCount','EH_Color.EH_EntryCount
  4911.             EH_EventDay.EH_EntryCount = strip(EH_EventDay.EH_EntryCount)
  4912.             EH_Easter.EH_EntryCount = EH_EventDay.EH_EntryCount
  4913.             EH_Event.EH_EntryCount = strip(EH_Event.EH_EntryCount)
  4914.             EH_HighlightType.EH_EntryCount = EH_HighlightTypeCyc.Easter
  4915.             EH_Keyword.EH_EntryCount = 'CalculateEDate'
  4916.           end
  4917.           else do
  4918.             parse var EH_HighlightData .','EH_DayOfWeek','EH_HighDate','EH_Event.EH_EntryCount','EH_Color.EH_EntryCount
  4919.             interpret "EH_DayOfWeek = Day."strip(EH_DayOfWeek, 'B', ' "'||"'")
  4920.             EH_HighDate = strip(EH_HighDate)
  4921.             EH_Event.EH_EntryCount = strip(EH_Event.EH_EntryCount)
  4922.             if pos('IMAGE', upper(EH_Keyword.EH_EntryCount)) > 0 then do
  4923.               if (pos(':', EH_Event.EH_EntryCount) == 0) & (pos('/', EH_Event.EH_EntryCount) == 0) then do
  4924.                 EH_Event.EH_EntryCount = ScriptDir'Images/'strip(EH_Event.EH_EntryCount, 'B', ' "'||"'")
  4925.               end
  4926.             end
  4927.             if datatype(EH_HighDate) == 'CHAR' then do
  4928.               /* Weekly/Biweekly events */
  4929.               EH_HighDate = upper(strip(EH_HighDate, 'B', "'"))
  4930.               EH_HighlightType.EH_EntryCount = EH_HighlightTypeCyc.BiOrWeekly
  4931.               interpret 'EH_WeekType.EH_EntryCount = EH_WeekTypeCyc.'EH_HighDate
  4932.               EH_EventOffset = EH_DayOfWeek - EH_StartDate
  4933.               EH_EventDay.EH_EntryCount = 1 + EH_EventOffset
  4934.               if EH_EventDay.EH_EntryCount < 1 then EH_EventDay.EH_EntryCount = EH_EventDay.EH_EntryCount + 7
  4935.               EH_WN = trunc((right(DateInfo('J', EH_Year''EH_Month''right(EH_EventDay.EH_EntryCount, 2, '0'), 'S'), 3) - EH_YearOffset - 1)/7 + 1)
  4936.               if ((EH_HighDate == 'EVEN') & (EH_WN//2 == 1)) | ((EH_HighDate == 'ODD') & (EH_WN//2 == 0)) then EH_EventDay.EH_EntryCount = EH_EventDay.EH_EntryCount + 7
  4937.             end
  4938.             else do
  4939.               EH_HighlightType.EH_EntryCount = EH_HighlightTypeCyc.Float
  4940.               interpret 'EH_First = Day.'DateInfo('W', EH_Year''EH_Month'01', 'S')
  4941.               EH_EventDay.EH_EntryCount = EH_HighDate + (EH_DayOfWeek - EH_First)
  4942.               if EH_First < EH_DayOfWeek then EH_EventDay.EH_EntryCount = EH_EventDay.EH_EntryCount - 7
  4943.               EH_TempDay = EH_EventDay.EH_EntryCount
  4944.               EH_Weeknumber.EH_EntryCount = 0
  4945.               if EH_HighDate > 28 then EH_Weeknumber.EH_EntryCount = 4
  4946.               else do
  4947.                 do until EH_TempDay < 0
  4948.                   EH_TempDay = EH_TempDay - 7
  4949.                   if EH_TempDay > 0 then EH_Weeknumber.EH_EntryCount = EH_Weeknumber.EH_EntryCount + 1
  4950.                 end
  4951.               end
  4952.             end
  4953.           end
  4954.         end
  4955.  
  4956.         if datatype(EH_EventDay.EH_EntryCount) == 'CHAR' then do
  4957.           interpret 'EH_Weekend.EH_EntryCount = EH_WeekendCyc.'upper(right(EH_EventDay.EH_EntryCount, 1))
  4958.           EH_EventDay.EH_EntryCount = left(EH_EventDay.EH_EntryCount, length(EH_EventDay.EH_EntryCount) - 1)
  4959.         end
  4960.         else EH_Weekend.EH_EntryCount = EH_WeekendCyc.OK
  4961.  
  4962.         if EH_EventDay.EH_EntryCount == '32' then EH_EventDay.EH_EntryCount = 'LD'
  4963.  
  4964.         EH_Event.EH_EntryCount = strip(EH_Event.EH_EntryCount, 'B', ' "'||"'")
  4965.         if right(EH_Event.EH_EntryCount, 1) == '#' then do
  4966.           EH_Holiday.EH_EntryCount = 128
  4967.           EH_Event.EH_EntryCount = left(EH_Event.EH_EntryCount, length(EH_Event.EH_EntryCount) - 1)
  4968.         end
  4969.         else EH_Holiday.EH_EntryCount = 0
  4970.       end
  4971.       EH_Color.EH_EntryCount = strip(EH_Color.EH_EntryCount, 'B', ' "'||"'")
  4972.       if EH_Color.EH_EntryCount == '' then EH_Color.EH_EntryCount = '<'Clear$'>'
  4973.     end
  4974.  
  4975.     call EH_CASortAndFind(1)
  4976.   end
  4977.  
  4978.   EH_HighEntry = EH_EntryCount
  4979.   if EH_EntryCount > 0 then do
  4980.     EH_CurrentPointer = 1
  4981.     EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  4982.   end
  4983.   else do
  4984.     EH_CurrentEntry = 0
  4985.     EH_CurrentPointer = 0
  4986.   end
  4987.  
  4988.   return
  4989. /**/
  4990.  
  4991. /***//*** EH_CASaveHighlightData ***/
  4992. EH_CASaveHighlightData:
  4993.   EH_Comment.EH_CurrentEntry = ReadCAGad('EH', EH_CommentGad)
  4994.   call EH_CAProcessEventGad(ReadCAGad('EH', EH_EventGad))
  4995.   do EH_i = 1 to EH_EntryCount
  4996.     EH_CurrentPointer     = EH_i
  4997.     EH_CurrentEntry       = EH_Pointer.EH_CurrentPointer
  4998.     EH_EventDay           = EH_EventDay.EH_CurrentEntry
  4999.     EH_Weekend            = EH_Weekend.EH_CurrentEntry
  5000.     EH_HighlightType      = EH_HighlightType.EH_CurrentEntry
  5001.     interpret 'EH_Keyword = EH_KeywordCode.'EH_HighlightType.EH_CurrentEntry''EH_Image.EH_CurrentEntry
  5002.  
  5003.     if EH_EventDay == 'LD' then EH_EventDay = 32
  5004.     if EH_Holiday.EH_CurrentEntry == 1 then EH_Event.EH_CurrentEntry = EH_Event.EH_CurrentEntry'#'
  5005.     if EH_WeekendCyc.EH_Weekend ~= 'OK' then EH_EventDay = EH_EventDay''EH_WeekendCYC.EH_Weekend
  5006.     if (upper(EH_Keyword) == 'HIGHLIGHT') | (upper(EH_Keyword) == 'IMAGE') then do
  5007.       EH_DataLine = EH_SelectMonth''EH_Keyword'.'EH_SelectMonth - 0'.'EH_EventDay' = 'QuoteIt(EH_Event.EH_CurrentEntry)
  5008.       if upper(EH_Keyword) == 'HIGHLIGHT' then EH_DataLine = EH_DataLine', 'QuoteIt(EH_Color.EH_CurrentEntry)
  5009.     end
  5010.     else if (upper(EH_Keyword) == 'CALCULATEDATE') | (upper(EH_Keyword) == 'CALCULATEIMAGE') then do
  5011.       EH_DayOfWeek = DateInfo('W', EH_Year''EH_Month''right(EH_EventDay.EH_CurrentEntry, 2, '0'), 'S')
  5012.       if EH_HighlightTypeCyc.EH_HighlightType == 'Float' then do
  5013.         interpret 'EH_DayNumber = Day.'EH_DayOfWeek
  5014.         if EH_Weeknumber.EH_CurrentEntry < 4 then do
  5015.           EH_DayNumber = EH_DayNumber + 1
  5016.           if EH_DayNumber == 7 then EH_DayNumber = 0
  5017.           interpret 'EH_DayOfWeek = Day.'EH_DayNumber
  5018.           EH_EventDay = 7 * (EH_Weeknumber.EH_CurrentEntry + 1)
  5019.         end
  5020.         else do
  5021.           EH_EventDay = Monthlength.EH_ShortMonth
  5022.           EH_TempDay = Monthlength.EH_ShortMonth - 29
  5023.           EH_DayNumber = EH_DayNumber - EH_TempDay
  5024.           if EH_DayNumber < 0 then EH_DayNumber = EH_DayNumber + 7
  5025.           else if EH_DayNumber > 6 then EH_DayNumber = EH_DayNumber - 7
  5026.           interpret 'EH_DayOfWeek = Day.'EH_DayNumber
  5027.         end
  5028.       end
  5029.       else EH_EventDay = "'"EH_WeekTypeCyc.EH_CurrentEntry"'"
  5030.       EH_DataLine = EH_SelectMonth''EH_Keyword'('EH_SelectMonth - 0', 'QuoteIt(EH_DayOfWeek)', 'EH_EventDay', 'QuoteIt(EH_Event.EH_CurrentEntry)
  5031.       if upper(EH_Keyword) == 'CALCULATEDATE' then EH_DataLine = EH_DataLine', 'QuoteIt(EH_Color.EH_CurrentEntry)
  5032.       EH_DataLine = EH_DataLine')'
  5033.     end
  5034.     else if EH_SelectMonth == 14 then
  5035.       EH_DataLine = 'CalculateEDate('EH_EventDay.EH_CurrentEntry', 'QuoteIt(EH_Event.EH_CurrentEntry)', 'QuoteIt(EH_Color.EH_CurrentEntry)')'
  5036.     if EH_Comment.EH_CurrentEntry ~= '' then EH_DataLine = EH_DataLine'  /* 'EH_Comment.EH_CurrentEntry' */'
  5037.     HighlightData.EH_SelectMonth.EH_i = EH_DataLine
  5038.   end
  5039.   MonthCount.EH_SelectMonth = EH_EntryCount
  5040.  
  5041.   return
  5042. /**/
  5043.  
  5044. /***//*** EH_CASetBiOrWeeklyGads ***/
  5045. EH_CASetBiOrWeeklyGads:
  5046.   call ToPIPE('EH', 'id 'EH_ButtonID.LD' dis=1 ref')
  5047.   if EH_EventDay.EH_CurrentEntry == 'LD' then do
  5048.     call ToPIPE('EH', 'id 'EH_ButtonID.LD' s=0 ref')
  5049.     EH_EventDay.EH_CurrentEntry = 1
  5050.     call ToPIPE('EH', 'id 'EH_ButtonID.1' s=1 ref')
  5051.     EH_DayShowing = 1
  5052.   end
  5053.  
  5054.   call ToPIPE('EH', 'id 'EH_HLTypeGad' dis=0 ref')
  5055.   call ToPIPE('EH', 'id 'EH_WeekNumberGad' dis=1 ref')
  5056.   call ToPIPE('EH', 'id 'EH_WeekTypeGad' dis=0 ref')
  5057.   call ToPIPE('EH', 'id 'EH_WeekendGad' dis=1 ref')
  5058.   call ToPIPE('EH', 'id 'EH_HolidayGad' dis=0 ref')
  5059.   return
  5060. /**/
  5061.  
  5062. /***//*** EH_CASetEvent ***/
  5063. EH_CASetEvent:
  5064.   EH_CurrentEntry = EH_Pointer.EH_CurrentPointer
  5065.   call EH_CASetPrevAndNext
  5066.  
  5067.   if EH_SelectMonth < 14 then do
  5068.     /* De-select existing date button */
  5069.     if EH_DayShowing ~= 0 then call ToPIPE('EH', 'id 'EH_ButtonID.EH_DayShowing' s=0 ref')
  5070.     /* Select current date button */
  5071.     EH_EventDay = EH_EventDay.EH_CurrentEntry
  5072.     EH_DayShowing = EH_EventDay
  5073.     EH_HighlightType = EH_HighlightType.EH_CurrentEntry
  5074.     call ToPIPE('EH', 'id 'EH_ButtonID.EH_EventDay' s=1')
  5075.     call ToPIPE('EH', 'id 'EH_HLTypeGad' s='EH_HighlightType.EH_CurrentEntry)
  5076.     if EH_HighlightType.EH_CurrentEntry == 0 then call EH_CASetFixedGads
  5077.     else if EH_HighlightType.EH_CurrentEntry == 1 then do
  5078.       call EH_CASetFloatGads
  5079.       call EH_CACheckWeekNumber
  5080.     end
  5081.     else if EH_HighlightType.EH_CurrentEntry == 2 then do
  5082.       call EH_CASetBiOrWeeklyGads
  5083.       call EH_CACheckWeekType
  5084.     end
  5085.     call ToPIPE('EH', 'id 'EH_WeekendGad' s='EH_Weekend.EH_CurrentEntry)
  5086.     call ToPIPE('EH', 'id 'EH_HolidayGad' s='EH_Holiday.EH_CurrentEntry' ref')
  5087.   end
  5088.   else call ToPIPE('EH', 'id 'EH_EasterGad' defn='EH_Easter.EH_CurrentEntry)
  5089.  
  5090.   call ToPIPE('EH', 'id 'EH_EventGad' gt="'EH_Event.EH_CurrentEntry'" ref')
  5091.   call ToPIPE('EH', 'id 'EH_CommentGad' gt="'EH_Comment.EH_CurrentEntry'" ref')
  5092.   call ToPIPE('EH', 'id 'EH_ColorGad' gt="'EH_Color.EH_CurrentEntry'" ref')
  5093.  
  5094.   return
  5095. /**/
  5096.  
  5097. /***//*** EH_CASetFixedGads ***/
  5098. EH_CASetFixedGads:
  5099.   call ToPIPE('EH', 'id 'EH_ButtonID.LD' dis=0 ref')
  5100.  
  5101.   call ToPIPE('EH', 'id 'EH_ColorGad' dis=0 ref')
  5102.   call ToPIPE('EH', 'id 'EH_HLTypeGad' dis=0 ref')
  5103.   call ToPIPE('EH', 'id 'EH_WeekNumberGad' dis=1 ref')
  5104.   call ToPIPE('EH', 'id 'EH_WeekTypeGad' dis=1 ref')
  5105.   call ToPIPE('EH', 'id 'EH_WeekendGad' dis=0 ref')
  5106.   call ToPIPE('EH', 'id 'EH_HolidayGad' dis=0 ref')
  5107.   call ToPIPE('EH', 'id 'EH_EasterGad' dis=1 ref')
  5108.   return
  5109. /**/
  5110.  
  5111. /***//*** EH_CASetFloatGads ***/
  5112. EH_CASetFloatGads:
  5113.   call ToPIPE('EH', 'id 'EH_ButtonID.LD' dis=1 ref')
  5114.   if EH_EventDay.EH_CurrentEntry == 'LD' then do
  5115.     call ToPIPE('EH', 'id 'EH_ButtonID.LD' s=0 ref')
  5116.     EH_EventDay.EH_CurrentEntry = 1
  5117.     call ToPIPE('EH', 'id 'EH_ButtonID.1' s=1 ref')
  5118.     EH_DayShowing = 1
  5119.   end
  5120.  
  5121.   call ToPIPE('EH', 'id 'EH_ColorGad' dis=0 ref')
  5122.   call ToPIPE('EH', 'id 'EH_HLTypeGad' dis=0 ref')
  5123.   call ToPIPE('EH', 'id 'EH_WeekNumberGad' dis=0 ref')
  5124.   call ToPIPE('EH', 'id 'EH_WeekTypeGad' dis=1 ref')
  5125.   call ToPIPE('EH', 'id 'EH_WeekendGad' dis=1 ref')
  5126.   call ToPIPE('EH', 'id 'EH_HolidayGad' dis=0 ref')
  5127.   call ToPIPE('EH', 'id 'EH_EasterGad' dis=1 ref')
  5128.   return
  5129. /**/
  5130.  
  5131. /***//*** EH_CASetMonthGads ***/
  5132. EH_CASetMonthGads:
  5133.   call ToPIPE('EH', 'id 'EH_EventGad' dis=0 ref')
  5134.   call ToPIPE('EH', 'id 'EH_ChooseEventGad' dis=0 ref')
  5135.   call ToPIPE('EH', 'id 'EH_CommentGad' dis=0 ref')
  5136.   call ToPIPE('EH', 'id 'EH_ColorGad' dis=0 ref')
  5137.  
  5138.   if EH_SelectMonth == 14 then do
  5139.     EH_DisableFlag = 1
  5140.     call ToPIPE('EH', 'id 'EH_HLTypeGad' dis=1 ref')
  5141.     call ToPIPE('EH', 'id 'EH_WeekNumberGad' dis=1 ref')
  5142.     call ToPIPE('EH', 'id 'EH_WeekTypeGad' dis=1 ref')
  5143.     call ToPIPE('EH', 'id 'EH_WeekendGad' dis=1 ref')
  5144.     call ToPIPE('EH', 'id 'EH_EasterGad' dis=0 ref')
  5145.   end
  5146.   else do
  5147.     call ToPIPE('EH', 'id 'EH_EasterGad' dis=1 ref')
  5148.     EH_DisableFlag = 0
  5149.   end
  5150.  
  5151.   do EH_Posn = 0 to 41
  5152.     if GadText.EH_Posn ~= '' then call ToPIPE('EH', 'id 'GadID.EH_Posn' dis='EH_DisableFlag' ref')
  5153.   end
  5154.  
  5155.   call ToPIPE('EH', 'id 'EH_HolidayGad' dis=0 ref')
  5156.   call ToPIPE('EH', 'id 'EH_DeleteEventGad' dis=0 ref')
  5157.  
  5158.   return
  5159. /**/
  5160.  
  5161. /***//*** EH_CASetPrevAndNext ***/
  5162. EH_CASetPrevAndNext:
  5163.   if EH_EntryCount < 2 then do
  5164.     call ToPIPE('EH', 'id 'EH_ListEventGad' dis=1')
  5165.     call ToPIPE('EH', 'id 'EH_CycleEventGad' dis=1')
  5166.   end
  5167.   else do
  5168.     call ToPIPE('EH', 'id 'EH_ListEventGad' dis=0 ref')
  5169.     call ToPIPE('EH', 'id 'EH_CycleEventGad' dis=0 ref')
  5170.   end
  5171.   return
  5172. /**/
  5173.  
  5174. /***//*** EH_CASetRequester ***/
  5175. call EH_CASetRequester:
  5176.   call ToPIPE('EH', 'id 0 s=256')
  5177.   if EH_DayShowing ~= 0 then call ToPIPE('EH', 'id 'EH_ButtonID.EH_DayShowing' s=0 ref')
  5178.   EH_DayShowing = 0
  5179.  
  5180.   EH_ShortMonth = EH_SelectMonth - 0
  5181.   if EH_ShortMonth > 12 then EH_ShortMonth = 1
  5182.   EH_Month = right(EH_ShortMonth, 2, "0")
  5183.   interpret 'EH_StartDate = Day.'DateInfo('W', EH_Year''EH_Month'01', 'S')
  5184.  
  5185.   MonthLength.2 = 29
  5186.   call ToPIPE('EH', 'id 'EH_MonthGad' s='EH_SelectMonth - 1)
  5187.   if EH_SelectMonth ~= 14 then do
  5188.     EH_ButtonID. = 0
  5189.     EH_GadText.  = ''
  5190.     EH_Day       = 0
  5191.     do EH_Week = 0 to 5
  5192.       do EH_WeekDay = 0 to 6
  5193.         EH_Posn = (EH_Week * 7) + EH_WeekDay
  5194.         if (EH_Posn >= EH_StartDate) & (EH_Posn < EH_StartDate + MonthLength.EH_ShortMonth + 1) then do
  5195.           EH_Day = EH_Day + 1
  5196.           if EH_Day > MonthLength.EH_ShortMonth then EH_Day = LD
  5197.           GadText.EH_Posn = EH_Day
  5198.           EH_ButtonID.EH_Day = GadID.EH_Posn
  5199.           interpret 'EH_Day.'GadID.EH_Posn' = EH_Day'
  5200.           call ToPIPE('EH', 'id 'GadID.EH_Posn' gt="'EH_Day'" dis=0')
  5201.         end
  5202.         else do
  5203.           GadText.EH_Posn = ''
  5204.           interpret 'drop EH_Day.'GadID.EH_Posn
  5205.           call ToPIPE('EH', 'id 'GadID.EH_Posn' gt="" dis=1')
  5206.         end
  5207.       end
  5208.     end
  5209.   end
  5210.  
  5211.   if UpdateBusy(Req, 1) == -1 then call EH_CACleanup
  5212.   call EH_CAReadData
  5213.  
  5214.   if UpdateBusy(Req, 1) == -1 then call EH_CACleanup
  5215.   EH_DayShowing = 0
  5216.   if EH_EntryCount > 0 then do
  5217.     call EH_CASetMonthGads
  5218.     call EH_CASetEvent
  5219.   end
  5220.   else call EH_CAGhostGads
  5221.  
  5222.   call ToPIPE('EH', 'id 0 s=512')
  5223.   return
  5224. /**/
  5225.  
  5226. /***//*** EH_CASortAndFind ***/
  5227. EH_CASortAndFind:
  5228.   parse arg SAF_CurrentEntry
  5229.   SortFile = ''
  5230.   do EH_i = 1 to EH_EntryCount
  5231.     SortFile = SortFile''right(EH_i, 3, "0")' 'EH_EventDay.EH_i||'0a'x
  5232.   end
  5233.   call writefile('pipe:FWC', strip(SortFile, 'B', '0a'x))
  5234.   address command 'sort pipe:FWC Pipe:FWC1 Colstart 5 numeric'
  5235.   SortedFile = ReadFile('pipe:FWC1')
  5236.   call openv('SortedFile')
  5237.   do EH_i = 1 to EH_EntryCount
  5238.     EH_Pointer.EH_i = left(readvln('SortedFile'), 3) - 0
  5239.     if EH_Pointer.EH_i == SAF_CurrentEntry then EH_CurrentPointer = EH_i
  5240.   end
  5241.   call closev('SortedFile')
  5242.   call EH_CAUpdateEventList
  5243.   call EH_CASetPrevAndNext
  5244.   return
  5245. /**/
  5246.  
  5247. /***//*** EH_CAUpdateEventList ***/
  5248. EH_CAUpdateEventList:
  5249.   EH_EventList = ''
  5250.   do UEL_i = 1 to EH_EntryCount
  5251.     EH_Entry = EH_Pointer.UEL_i
  5252.     EH_EventList = EH_EventList'|'EH_Event.EH_Entry
  5253.   end
  5254.   EH_EventList = strip(EH_EventList, 'L', '|')
  5255.   call ToPipe('EH', 'id 'EH_ListEventGad' defn='EH_EntryCount' cl="'EH_EventList'"')
  5256.  
  5257.   return
  5258. /**/
  5259.  
  5260. /**/
  5261.  
  5262. /**/
  5263.  
  5264. /***//*** FilePart (PROCEDURE) ***/
  5265. FilePart: PROCEDURE
  5266.   parse arg FileWithPath
  5267.   return substr(FileWithPath, max(lastpos(':', FileWithPath), lastpos('/', FileWithPath)) + 1)
  5268. /**/
  5269.  
  5270. /***//*** GetAppColors () ***/
  5271. GetAppColors:
  5272.   if App == 'FW' then do
  5273.     FWPrefs = ReadFile(CurrentDir'FWFiles/FW.Prefs')
  5274.     ColorTable = pos('SWCL', FWPrefs) + 12
  5275.     EndTable = pos('STUP', FWPrefs)
  5276.     ColorCount = 0
  5277.     Do CTPos = ColorTable to EndTable by 20
  5278.       ColorRegister.ColorCount = c2x(substr(FWPrefs, CTPos - 3, 3))
  5279.       FWColorName = substr(FWPrefs, CTPos, 16)
  5280.       ColorList.ColorCount = left(FWColorName, pos('00'x, FWColorName) - 1)
  5281.       NCColorList.ColorCount = ColorList.ColorCount
  5282.       if ColorRegister.ColorCount = '000000' then Black$ = ColorList.ColorCount
  5283.       if ColorRegister.ColorCount = 'FFFFFF' then White$ = ColorList.ColorCount
  5284.       ColorCount = ColorCount + 1
  5285.     end
  5286.     NCColorCount = ColorCount
  5287.     NCColorList.COUNT = NCColorCount
  5288.     ColorList.ColorCount = '<'Clear$'>'
  5289.     ColorCount = ColorCount + 1
  5290.     ColorList.COUNT = ColorCount
  5291.     if symbol('Black$') == 'LIT' then do
  5292.       call AddMsg('W', "The color black can't be found; "ColorList.0" used instead.")
  5293.       Black$ = ColorList.0
  5294.     end
  5295.     if symbol('White$') == 'LIT' then do
  5296.       call AddMsg('W', "The color white can't be found; "ColorList.1" used instead.")
  5297.       White$ = ColorList.1
  5298.     end
  5299.   end
  5300.   else if App == 'PGS' then do
  5301.     GETFONTLIST FontList
  5302.     FontList.COUNT = result
  5303.  
  5304.     PGSColors = ReadFile(CurrentDir''PgmName'.colors')
  5305.     ColorCount = 0
  5306.     StartTag = pos('TG'||'00'x, PGSColors)
  5307.     do while StartTag ~= 0
  5308.       Color = substr(PGSColors, StartTag + 10, c2d(substr(PGSColors, StartTag + 9, 1)))
  5309.       AccentMarker = pos(d2c(129), Color)
  5310.       do while AccentMarker > 0
  5311.         Color = overlay(d2c(c2d(substr(Color, AccentMarker + 1, 1)) + 128), delstr(Color, AccentMarker, 1), AccentMarker)
  5312.         AccentMarker = pos(d2c(129), Color)
  5313.       end
  5314.       ColorList.ColorCount = Color
  5315.       NCColorList.ColorCount = ColorList.ColorCount
  5316.       ColorCount = ColorCount + 1
  5317.       StartTag = pos('TG'||'00'x, PGSColors, StartTag + 10)
  5318.     end
  5319.     NCColorCount = ColorCount
  5320.     NCColorList.COUNT = NCColorCount
  5321.     ColorList.ColorCount = '<'Clear$'>'
  5322.     ColorCount = ColorCount + 1
  5323.     ColorList.COUNT = ColorCount
  5324.     White$ = ColorList.0
  5325.     Black$ = ColorList.1
  5326.   end
  5327.  
  5328.   DefaultColor = Black$
  5329.   DefaultBackground = White$
  5330.  
  5331.   return
  5332. /**/
  5333.  
  5334. /***//*** GetFontWidth (GFW) ***/
  5335. GetFontWidth:
  5336.   parse arg GFW_FontType, GFW_FontStyle, GFW_Char
  5337.  
  5338.   GFW_ID = PrintText(.5, .5, GFW_FontType, GFW_FontStyle, Black$, Width.GFW_FontType, GFW_Char)
  5339.  
  5340.   if App == 'FW' then do
  5341.     REDRAW
  5342.     GETOBJECTCOORDS GFW_ID; parse var RESULT . . . GFW_Width .
  5343.     DELETEOBJECT GFW_ID
  5344.   end
  5345.   else if App == 'PGS' then do
  5346.     GETTEXTOBJ POSITION GFW_Text OBJECTID GFW_ID WINDOW winName
  5347.     GFW_Width = GFW_Text.Right - GFW_Text.Left
  5348.     DELETEOBJECT OBJECTID GFW_ID WINDOW winName
  5349.   end
  5350.  
  5351.   return GFW_Width
  5352. /**/
  5353.  
  5354. /***//*** GetHeight (GH) ***/
  5355. GetHeight:
  5356.   parse arg GH_FontType
  5357.  
  5358.   if App == 'FW' then do
  5359.     TEXTBLOCKTYPEPREFS SIZE FSize.GH_FontType FONT Font.GH_FontType
  5360.     DRAWTEXTBLOCK 1 1 1 'A'; GH_id = result
  5361.     GETOBJECTCOORDS GH_id; Parse Var result . . . . GH_Text.Height
  5362.   end
  5363.   else if App == 'PGS' then do
  5364.     DRAWTEXTOBJ 0 0 WINDOW winName; GH_id = result
  5365.     SELECTTEXT AT 0 0 WINDOW winName
  5366.     BEGINCOMMANDCAPTURE
  5367.       SETLEADING RELATIVE 100
  5368.       SETTYPESIZE FSize.GH_FontType WINDOW winName
  5369.       SETFONT Font.GH_FontType WINDOW winName
  5370.     ENDCOMMANDCAPTURE
  5371.     INSERT 'A' WINDOW winName
  5372.     GETTEXTOBJ POSITION GH_Text OBJECTID GH_id WINDOW winName
  5373.     GH_Text.Height = GH_Text.Bottom - GH_Text.Top
  5374.     DELETEOBJECT OBJECTID GH_id WINDOW winName
  5375.   end
  5376.  
  5377.   return GH_Text.Height
  5378. /**/
  5379.  
  5380. /***//*** GetID (GI) ***/
  5381. GetID:
  5382. parse arg GI_var
  5383.  
  5384. return id.GI_var
  5385. /**/
  5386.  
  5387. /***//*** GetMaxWidth (GMW) ***/
  5388. GetMaxWidth:
  5389.   parse arg GMW_Stem, GMW_Count
  5390.  
  5391.   GMW_maxwidth = 0
  5392.  
  5393.   if App == 'FW' then do
  5394.     do GMW_i = 0 to GMW_Count
  5395.       interpret 'GMW_ObjectID = 'GMW_Stem'.'GMW_i
  5396.       GETOBJECTCOORDS GMW_ObjectID
  5397.       Parse Var result . . . GMW_width .
  5398.       GMW_maxwidth = max(GMW_width, GMW_maxwidth)
  5399.     end
  5400.   end
  5401.   else if App == 'PGS' then do
  5402.     do GMW_i = 0 to GMW_Count
  5403.       interpret 'GMW_ObjectID = 'GMW_Stem'.'GMW_i
  5404.       SELECTOBJECT ObjectID GMW_ObjectID WINDOW winName
  5405.       GETTEXTOBJ POSITION GMW_Temp OBJECTID GMW_ObjectID WINDOW winName
  5406.       GMW_width = GMW_Temp.Right - GMW_Temp.Left
  5407.       GMW_maxwidth = max(GMW_width, GMW_maxwidth)
  5408.     end
  5409.   end
  5410.  
  5411.   return GMW_maxwidth
  5412. /**/
  5413.  
  5414. /***//*** GetMiniMax (GMM) ***/
  5415. GetMiniMax:
  5416.   parse arg GMM_FontType
  5417.  
  5418.   NormalWidth.Widest = 0
  5419.   BoldWidth.Widest = 0
  5420.   do GMM_i = 0 to 9
  5421.     NormalWidthID.GMM_i = PrintText(1, 1, GMM_FontType, 'N', Black$, Width.GMM_FontType, GMM_i)
  5422.     BoldWidthID.GMM_i = PrintText(1, 1, GMM_FontType, 'B', Black$, Width.GMM_FontType, GMM_i)
  5423.   end
  5424.   if App == 'FW' then REDRAW
  5425.   do GMM_i = 0 to 9
  5426.     NormalWidth.GMM_i = GetWidth(NormalWidthID.GMM_i)
  5427.     BoldWidth.GMM_i = GetWidth(BoldWidthID.GMM_i)
  5428.     NormalWidth.Widest = max(NormalWidth.Widest, NormalWidth.GMM_i)
  5429.     BoldWidth.Widest = max(BoldWidth.Widest, BoldWidth.GMM_i)
  5430.     if App == 'PGS' then do
  5431.       DELETEOBJECT OBJECTID NormalWidthID.GMM_i WINDOW winName
  5432.       DELETEOBJECT OBJECTID BoldWidthID.GMM_i WINDOW winName
  5433.     end
  5434.   end
  5435.  
  5436.   return
  5437. /**/
  5438.  
  5439. /***//*** GetPhases (GP) ***/
  5440. GetPhases:
  5441.   parse arg GP_Y, GP_Month
  5442.   if DateLib == 1 then do
  5443.     GP_Phase.0 = 'N'
  5444.     GP_Phase.1 = '1'
  5445.     GP_Phase.2 = 'F'
  5446.     GP_Phase.3 = '3'
  5447.  
  5448.     GP_JD = date_GregorianToJD(1, GP_Month, GP_Y)
  5449.     do GP_SeqDate = GP_JD - 22 to GP_JD + 39
  5450.       call date_JDToGregorian(GP_SeqDate, 'GP_DAY GP_MONTH GP_YEAR')
  5451.  
  5452.       do GP_Phase = 0 to 3
  5453.         GP_SeqDate = date_GregorianMoonPhase(GP_Day, GP_Month, GP_Year, GP_Phase)
  5454.         call date_JDToGregorian(GP_SeqDate, 'GP_DAY GP_MONTH GP_YEAR')
  5455.         MoonPhase.GP_Year.GP_Month.GP_Day = GP_Phase.GP_Phase
  5456.       end
  5457.     end
  5458.   end
  5459.   else do
  5460.     /* Routine to determine the dates of the new and full moons for a given year */
  5461.     /* obtained from the Sky & Telescope web site. The basic program from which  */
  5462.     /* the following was derived originally appeared in Astronomical Computing,  */
  5463.     /* Sky & Telescope, March, 1985                                              */
  5464.     GP_R1 = PI(0) / 180
  5465.     GP_NextPhase = 29.530588853 / 4
  5466.     GP_U  = 0
  5467.  
  5468.     GP_K0 = trunc((GP_Y - 1900) * 12.3685)
  5469.     GP_T  = (GP_Y - 1899.5) / 100
  5470.     GP_T2 = GP_T*GP_T
  5471.     GP_T3 = GP_T*GP_T*GP_T
  5472.     GP_J0 = 2415020 + 29 * GP_K0
  5473.     GP_F0 = 0.0001178 * GP_T2 - 0.000000155 * GP_T3 + 0.75933 + 0.53058868 * GP_K0 - 0.000837 * GP_T - 0.000335 * GP_T2
  5474.  
  5475.     GP_J0  = GP_J0 + trunc(GP_F0)
  5476.     GP_F0  = GP_F0 - trunc(GP_F0)
  5477.  
  5478.     GP_M0 = GP_K0 * 0.08084821133
  5479.     GP_M0 = 360 * (GP_M0 - trunc(GP_M0)) + 359.2242 - 0.0000333 * GP_T2 - 0.00000347 * GP_T3
  5480.     GP_M1 = GP_K0 * 0.07171366128
  5481.     GP_M1 = 360 * (GP_M1 - trunc(GP_M1)) + 306.0253 + 0.0107306 * GP_T2 + 0.00001236 * GP_T3
  5482.     GP_B1 = GP_K0 * 0.08519585128
  5483.     GP_B1 = 360 * (GP_B1 - trunc(GP_B1)) + 21.2964 - 0.0016528 * GP_T2 - 0.00000239 * GP_T3
  5484.     do GP_K9 = 0 to 28
  5485.       GP_J  = GP_J0 + 14 * GP_K9
  5486.       GP_F  = GP_F0 + 0.765294 * GP_K9
  5487.       GP_K  = GP_K9 / 2
  5488.       GP_M5 = (GP_M0 + GP_K * 29.10535608) * GP_R1
  5489.       GP_M6 = (GP_M1 + GP_K * 385.81691806) * GP_R1
  5490.       GP_B6 = (GP_B1 + GP_K * 390.67050646) * GP_R1
  5491.       GP_F  = GP_F - 0.4068 * SIN(GP_M6) + (0.1734 - 0.000393 * GP_T) * SIN(GP_M5) + 0.0161 * SIN(2 * GP_M6)
  5492.       GP_F  = GP_F + 0.0104 * SIN(2 * GP_B6) - 0.0074 * SIN(GP_M5 - GP_M6) - 0.0051 * SIN(GP_M5 + GP_M6)
  5493.       GP_F  = GP_F + 0.0021 * SIN(2 * GP_M5) + 0.0010 * SIN(2 * GP_B6 - GP_M6)
  5494.       GP_J  = GP_J + trunc(GP_F)
  5495.       GP_F  = GP_F - trunc(GP_F)
  5496.  
  5497.       GP_Converted  = ConvertJ(GP_F, GP_J)
  5498.       GP_Y          = word(GP_Converted, 1) - 0
  5499.       GP_M          = word(GP_Converted, 2) - 0
  5500.       GP_Day        = word(GP_Converted, 3) - 0
  5501.       GP_Hrs        = word(GP_Converted, 4)
  5502.       if GP_U = 0 then do
  5503.         MoonPhase.GP_Y.GP_M.GP_Day = 'N'
  5504.         GP_FQ = DateInfo('S', trunc(DateInfo('I', GP_Y''right(GP_M, 2, '0')''right(GP_Day, 2, '0'), 'S') + GP_Hrs + GP_NextPhase))
  5505.         GP_Y = left(GP_FQ, 4)
  5506.         GP_M = strip(substr(GP_FQ, 5, 2), 'L', '0')
  5507.         GP_Day = strip(right(GP_FQ, 2), 'L', '0')
  5508.         MoonPhase.GP_Y.GP_M.GP_Day = '1'
  5509.       end
  5510.       if GP_U = 1 then do
  5511.         MoonPhase.GP_Y.GP_M.GP_Day = 'F'
  5512.         GP_TQ = DateInfo('S', trunc(DateInfo('I', GP_Y''right(GP_M, 2, '0')''right(GP_Day, 2, '0'), 'S') + GP_Hrs + GP_NextPhase))
  5513.         GP_Y = left(GP_TQ, 4)
  5514.         GP_M = strip(substr(GP_TQ, 5, 2), 'L', '0')
  5515.         GP_Day = strip(right(GP_TQ, 2), 'L', '0')
  5516.         MoonPhase.GP_Y.GP_M.GP_Day = '3'
  5517.       end
  5518.       GP_U = GP_U + 1
  5519.       if GP_U = 2 then GP_U = 0
  5520.     end
  5521.   end
  5522. return 0
  5523. /**/
  5524.  
  5525. /***//*** GetSetupInfo (GSI) ***/
  5526. GetSetupInfo:
  5527.   if exists(ScriptDir'FWC.dat') then call ConvertChangesFile
  5528.   else do
  5529.     PrefsFile = ReadFile('ENV:FWCalendar') /* Determine existing data file */
  5530.     if (PrefsFile == '') | (exists(PrefsFile) == 0) then do
  5531.       /* Create environment variable if it doesn't exist */
  5532.       PrefsFile = 'Default'
  5533.       call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  5534.     end
  5535.   end
  5536.  
  5537.   if PrefsFile ~= 'Default' then do
  5538.     GSI_Data = ReadFile(PrefsFile)
  5539.     GSI_UpperData = upper(GSI_Data)
  5540.     interpret ReadToEOL(pos('STORAGE', GSI_UpperData), GSI_UpperData)
  5541.     interpret ReadToEOL(pos('FORCEBGUI', GSI_UpperData), GSI_UpperData)
  5542.     interpret ReadToEOL(pos('HOSTSCREEN', GSI_UpperData), GSI_UpperData)
  5543.  
  5544.     if (ForceBGUI == 1) & (RexxBGUILib ~= 1) then call AddBGUI
  5545.     if HostScreen ~= '' then AppScreen = HostScreen
  5546.   end
  5547.  
  5548.   call GetAppColors
  5549.   if App == 'PGS' then do
  5550.     GETDOCUMENTS dummy; DocCount = result
  5551.     if DocCount > 0 then do
  5552.       CLOSEDOCUMENT ALERT
  5553.       GETDOCUMENTS dummy; DocCount = result
  5554.     end
  5555.   end
  5556.  
  5557.   if ClassAct == 1 then Req = OpenBusy(PrepReq$, 21 + (ColorList.Count - 1))
  5558.   else Req = OpenBusy(PrepReq$, 14)
  5559.  
  5560.   Year = left(date('S'),4)
  5561.   ThisMonth = left(date('U'), 2) + 0
  5562.  
  5563.   if (owner == 'rgoertz') & (CallHost == 'REXX') then CalMonth = ThisMonth
  5564.   else do
  5565.     CalMonth = getclip('FWC_CalMonth')
  5566.     if datatype(CalMonth) == 'CHAR' then do
  5567.       CalMonth = ThisMonth
  5568.       AddYear = 0
  5569.     end
  5570.     else do
  5571.       CalMonth = CalMonth + 1
  5572.       if CalMonth = 13 then do
  5573.         CalMonth = 1
  5574.         AddYear = 1
  5575.       end
  5576.       else AddYear = 0
  5577.     end
  5578.     CalYear = getclip('FWC_CalYear')
  5579.     if (CalYear ~= '') & (DataType(CalYear) == 'NUM') then Year = CalYear + AddYear
  5580.   end
  5581.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  5582.  
  5583.   call InitializeVariables
  5584.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  5585.  
  5586.   address command 'makedir >NIL: 'left(Storage, length(Storage) - 1)
  5587.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  5588.  
  5589.   WarningsSoFar = WarningCount
  5590.   if ClassAct == 1 then call DoSetupReq_CA
  5591.   else do
  5592.     do until Reset == 0
  5593.       if Req == 0 then Req = OpenBusy(PrepReq$, 11)
  5594.       WarningCount = WarningsSoFar
  5595.       call ReadData
  5596.       if UpdateBusy(Req, 1) == -1 then call Cleanup
  5597.       call DoSetupReq_BGUI
  5598.       if Reset > 0 then call bguiwinclose(winID)
  5599.       if Reset == 2 then call CleanUp
  5600.     end
  5601.   end
  5602.  
  5603.   Year = EnteredYear
  5604.  
  5605.   if ImageClass.0 ~= '' then do
  5606.     do GSI_i = 0 to ImageClass.Count - 1
  5607.       parse var ImageFile.GSI_i ImageFile.GSI_i ',' GSI_DX ',' GSI_DY
  5608.       GSI_DX = strip(GSI_DX, 'B', '" '||"'");if GSI_DX == '' then GSI_DX = 0
  5609.       GSI_DY = strip(GSI_DY, 'B', '" '||"'");if GSI_DY == '' then GSI_DY = 0
  5610.       if (pos('/', ImageFile.GSI_i) == 0) & (pos(':', ImageFile.GSI_i) == 0) then
  5611.         ImageFile.GSI_i = ScriptDir'Images/'strip(ImageFile.GSI_i, 'B', ' "'||"'")
  5612.       ImageDX.GSI_i = GSI_DX
  5613.       ImageDY.GSI_i = GSI_DY
  5614.     end
  5615.   end
  5616.  
  5617.   if EndWeek < 0 then EndWeek = StartWeek - 1
  5618.   if EndWeek < 0 then EndWeek = 6
  5619.   if EndWeek < StartWeek then WeekdayCount = EndWeek + 7 - StartWeek
  5620.   else WeekdayCount = EndWeek - StartWeek
  5621.  
  5622.   do i = 0 to 6
  5623.     val = i - StartWeek
  5624.     if val < 0 then val = 7 + val
  5625.     interpret 'Day.'D.i '=' val
  5626.     interpret 'Day.val = 'D.i'$'
  5627.   end
  5628.  
  5629.   if ShiftDown == 0 then call WriteData
  5630.  
  5631.   if ClassAct == 1 then call close('CA')
  5632.   else call bguiwinclose(winID)
  5633.  
  5634.   interpret 'GfxCmd = GfxCmd.'GfxApp
  5635.   interpret 'GfxTemplate = GfxTemplate.'GfxApp
  5636.  
  5637.   return
  5638. /**/
  5639.  
  5640. /***//*** GetSRSS (GS) ***/
  5641. GetSRSS:
  5642.   parse arg GS_IDay
  5643.  
  5644.   GS_EDay = translate(DateInfo('E', GS_IDay, 'I'), '-', '/')
  5645.   if AdjustDST ~= 0 then do
  5646.     if GS_IDay < StartDST | GS_IDay >= EndDST then GS_Status = WriteFile('ENV:suncalc/dst', 0)
  5647.     else GS_Status = WriteFile('ENV:suncalc/dst', 1)
  5648.   end
  5649.   address command Storage'suncalc > 'Storage'SRSS.txt date='GS_EDay' text="$SR $SS"'
  5650.   return ReadFile(Storage'SRSS.txt')
  5651. /**/
  5652.  
  5653. /***//*** GetWidth (GW) ***/
  5654. GetWidth:
  5655.   parse arg GW_ID
  5656.  
  5657.   if App == 'FW' then do
  5658.     GETOBJECTCOORDS GW_ID
  5659.     Parse Var result . . . GW_width .
  5660.   end
  5661.   else if App == 'PGS' then do
  5662.     SELECTOBJECT OBJECTID GW_ID WINDOW winName
  5663.     GETTEXTOBJ POSITION GW_Temp OBJECTID GW_ID WINDOW winName
  5664.     GW_width = GW_Temp.Right - GW_Temp.Left
  5665.   end
  5666.  
  5667.   return GW_width
  5668. /**/
  5669.  
  5670. /***//*** HalveBox (HB) ***/
  5671. HalveBox:
  5672.   parse arg HB_ID
  5673.  
  5674.   if App == 'FW' then do
  5675.     GETOBJECTCOORDS HB_ID
  5676.     parse var result . HB_Left HB_Top HB_Width HB_Height
  5677.     SETOBJECTCOORDS HB_ID 1 HB_Left HB_Top HB_Width HB_Height/2
  5678.   end
  5679.   else if App == 'PGS' then do
  5680.     GETBOX POSITION HB_Coords OBJECTID HB_ID WINDOW winName
  5681.     HB_Bottom = HB_Coords.Top + (HB_Coords.Bottom - HB_Coords.Top) / 2
  5682.     EDITBOX POSITION HB_Coords.Left HB_Coords.Top HB_Coords.Right HB_Bottom OBJECTID HB_ID WINDOW winName
  5683.   end
  5684.  
  5685.   return HB_ID
  5686. /**/
  5687.  
  5688. /***//*** PgmVer (PROCEDURE) ***/
  5689. PgmVer: PROCEDURE
  5690.   parse arg Program
  5691.  
  5692.   address command 'version 'Program '>PIPE:FWC file'
  5693.  
  5694.   return strip(word(ReadFile('PIPE:FWC'), 2))
  5695. /**/
  5696.  
  5697. /***//*** MemberID (MI) ***/
  5698. MemberID:
  5699.   parse arg MI_Member, MI_Array, MI_Count, MI_Start
  5700.  
  5701.   if MI_Count == '' then interpret 'MI_Count = 'MI_Array'.Count'
  5702.   if MI_Start == '' then do
  5703.     if symbol(MI_Array'.Start') == 'VAR' then interpret 'MI_Start = 'MI_Array'.Start'
  5704.     else MI_Start = 0
  5705.   end
  5706.  
  5707.   do MI_i = MI_Start to MI_Start + MI_Count - 1
  5708.     if upper(value(MI_Array'.'MI_i)) == upper(MI_Member) then return MI_i
  5709.   end
  5710.   return -1
  5711. /**/
  5712.  
  5713. /***//*** MiniCalPreCalc (MCPC) ***/
  5714. MiniCalPreCalc:
  5715.   parse arg MCPC_FontType, MCPC_CalWidth
  5716.  
  5717.   Width.MCPC_FontType = 100 * min(1, MCPC_CalWidth / (22 * BoldWidth.Widest))
  5718.   if App == 'FW' then Width.MCPC_FontType = trunc(Width.MCPC_FontType)
  5719.  
  5720.   do MCPC_i = 0 to 9
  5721.     NormalWidth.MCPC_i = NormalWidth.MCPC_i * Width.MCPC_FontType / 100
  5722.     BoldWidth.MCPC_i   = BoldWidth.MCPC_i * Width.MCPC_FontType / 100
  5723.   end
  5724.   NormalWidth.Widest = NormalWidth.Widest * Width.MCPC_FontType / 100
  5725.   BoldWidth.Widest = BoldWidth.Widest * Width.MCPC_FontType / 100
  5726. return
  5727. /**/
  5728.  
  5729. /***//*** ParseVariables (PV) ***/
  5730. ParseVariables:
  5731. parse arg PV_Line
  5732.  
  5733. PV_String = translate(PV_Line,,'=(+-*/,)"'||"'",' ')
  5734. PV_VarString = ''
  5735. PV_Var.      = '00'x
  5736. PV_LongVar   = 4
  5737. PV_LIT       = ''
  5738. PV_Count     = 0
  5739.  
  5740. do PV_i = 1 to words(PV_String)
  5741.   PV_Word = word(PV_String, PV_i)
  5742.   if pos(PV_Word'(', PV_Line) > 0 then iterate
  5743.   if datatype(PV_Word) == 'CHAR' then do
  5744.     if (symbol(PV_Word) == 'LIT') then PV_LIT = PV_LIT''PV_Word', '
  5745.     if (symbol(PV_Word) == 'VAR') | (pos('.', PV_Word) > 0) then do
  5746.       if symbol(PV_Word) == 'VAR' then do
  5747.         PV_LongVar = max(PV_LongVar, length(PV_Word) + 2)
  5748.         if PV_Var.PV_Word == '00'x then do
  5749.           PV_Count = PV_Count + 1
  5750.           PV_Var.PV_Count = PV_Word
  5751.           PV_Var.PV_Word  = value(PV_Word)
  5752.         end
  5753.       end
  5754.       if pos('.', PV_Word) > 0 then do
  5755.         PV_CompoundParts = subword(translate(PV_Word,,'.', ' '), 2)
  5756.         do PV_j = 1 to words(PV_CompoundParts)
  5757.           PV_Subword = word(PV_CompoundParts, PV_j)
  5758.           PV_LongVar = max(PV_LongVar, length(PV_SubWord) + 2)
  5759.           if PV_Var.PV_SubWord == '00'x then do
  5760.             PV_Count = PV_Count + 1
  5761.             PV_Var.PV_Count = PV_SubWord
  5762.             if symbol(PV_Subword) == 'LIT' then PV_Var.PV_SubWord  = 'LIT'
  5763.             else PV_Var.PV_SubWord  = value(PV_SubWord)
  5764.           end
  5765.         end
  5766.       end
  5767.     end
  5768.   end
  5769. end
  5770.  
  5771. do PV_i = 1 to PV_Count
  5772.   PV_Word = PV_Var.PV_i
  5773.   if length(PV_Var.PV_Word) > 50 then PV_Var.PV_Word = left(PV_Var.PV_Word, 50)'...'
  5774.   PV_Var.PV_Word = translate(PV_Var.PV_Word,,'0a'x||'0d'x||'00'x,'bb'x)
  5775.   PV_VarString = PV_VarString''right(PV_Word, PV_LongVar)' = 'PV_Var.PV_Word||'0a'x
  5776. end
  5777.  
  5778. if PV_LIT ~= '' then PV_VarString = right('LIT', PV_LongVar)' = 'strip(PV_LIT, 'B', ' ,')||'0a'x||PV_VarString
  5779. return PV_VarString
  5780. /**/
  5781.  
  5782. /***//*** PathPart (PROCEDURE) ***/
  5783. PathPart: PROCEDURE
  5784.   parse arg FileWithPath
  5785.   return left(FileWithPath, max(lastpos(':', FileWithPath), lastpos('/', FileWithPath)))
  5786. /**/
  5787.  
  5788. /***//*** Pi (PROCEDURE) ***/
  5789. Pi:
  5790.   return 3.1415926536
  5791. /**/
  5792.  
  5793. /***//*** PrintHighlight (PH) ***/
  5794. PrintHighlight:
  5795.   parse arg PH_Event, PH_Type
  5796.  
  5797.   PH_Type = upper(PH_Type)
  5798.   MaxCompression = MinWidth / 100
  5799.   CenterText = 0
  5800.   if PH_Type ~= 'HIGHLIGHT' then do
  5801.     HighlightOffset = 0
  5802.     if PH_Type == 'RANDOM' then do
  5803.       MaxCompression = MinRandomWidth / 100
  5804.       if BackgroundColor == '<'Clear$'>' then TextColor = Color.Random
  5805.       else TextColor = AltColor.Random
  5806.       CenterText = CenterRandom
  5807.     end
  5808.     if PH_Type == 'HISTORY' then do
  5809.       MaxCompression = MinHistoryWidth / 100
  5810.       if BackgroundColor == '<'Clear$'>' then TextColor = Color.History
  5811.       else TextColor = AltColor.History
  5812.       CenterText = CenterHistory
  5813.     end
  5814.   end
  5815.  
  5816.   /* Fit line(s) into allowable space */
  5817.   PH_Textline         = 0
  5818.   PH_Text.            = ''
  5819.   PH_Text.PH_Textline = PH_Event
  5820.  
  5821.   Do until PH_Text.PH_Nextline == ''
  5822.     PH_AllowedWidth = BoxWidth - 2 * CurveOffset - HighlightOffset
  5823.     PH_Nextline = PH_Textline + 1
  5824.     if PH_Textline == 0 then PH_Indent.PH_Textline = 0
  5825.     else PH_Indent.PH_Textline = Width.WidthOfDate1
  5826.     if (PH_Type == 'RANDOM') | (PH_Type == 'HISTORY') then PH_Indent.PH_Textline = 0
  5827.     PH_AllowedWidth = PH_AllowedWidth - PH_Indent.PH_Textline
  5828.  
  5829.     if PH_Event == '' then do
  5830.       PH_Text.PH_TextLine = ''
  5831.       iterate
  5832.     end
  5833.     if App == 'FW' & length(PH_Text.PH_Textline) > 37 then do
  5834.       PH_Wordbreak = lastpos(' ', PH_Text.PH_Textline, 37)
  5835.       PH_Text.PH_Nextline = strip(substr(PH_Text.PH_Textline, PH_Wordbreak)' 'PH_Text.PH_Nextline)
  5836.       PH_Text.PH_Textline = strip(left(PH_Text.PH_Textline, PH_Wordbreak))
  5837.     end
  5838.     PH_ID = PrintText(1, 1, Highlight, 'N', Color.Highlight, Width.Highlight, PH_Text.PH_Textline)
  5839.     if App == 'FW' then redraw
  5840.     PH_TextWidth.PH_Textline = GetWidth(PH_ID)
  5841.     if App == 'FW' then DELETEOBJECT PH_ID
  5842.     else if App == 'PGS' then do
  5843.       SELECTOBJECT ObjectID PH_ID WINDOW winName
  5844.       DELETEOBJECT ObjectID PH_ID WINDOW winName
  5845.     end
  5846.  
  5847.     PH_NeededCompression.PH_Textline = min(1, PH_AllowedWidth/PH_TextWidth.PH_Textline)
  5848.     if (PH_NeededCompression.PH_Textline < MaxCompression) & (Words(PH_Text.PH_Textline) > 1) then do
  5849.       /* Move last word to next line */
  5850.       PH_Wordbreak     = lastpos(' ', PH_Text.PH_Textline)
  5851.       PH_Text.PH_Nextline = strip(substr(PH_Text.PH_Textline, PH_Wordbreak)' 'PH_Text.PH_Nextline)
  5852.       PH_Text.PH_Textline = strip(left(PH_Text.PH_Textline, PH_Wordbreak))
  5853.     end
  5854.     else if PH_Text.PH_Nextline ~= '' then PH_Textline = PH_Textline + 1
  5855.   end
  5856.  
  5857.   if PH_Text.0 ~= '' then do
  5858.     PH_LineCount = PH_Textline
  5859.     MaxCompression = 1
  5860.     do PH_i = 0 to PH_LineCount
  5861.       MaxCompression = min(MaxCompression, PH_NeededCompression.PH_i)
  5862.     end
  5863.     PH_Width = MaxCompression * Width.Highlight
  5864.     if App == 'FW' then PH_Width = min(max(trunc(PH_Width), 4), 255)
  5865.  
  5866.     if (PH_Type == 'RANDOM') | (PH_Type == 'HISTORY') then  DailyHLCount = HighlightRows - PH_LineCount - 1
  5867.  
  5868.     do PH_TextLine = 0 to PH_LineCount
  5869.       if PH_Text.PH_TextLine ~= '' then do
  5870.         TextLeft = BoxLeft + CurveOffset + HighlightOffset * (DailyHLCount * Height.Highlight < Height.Date * TextBase)
  5871.         PH_TextTop = BoxTop + DailyHLCount * Height.Highlight
  5872.         if (BHeight == BoxHeight/2) & (PH_Type ~= 'HIGHLIGHT') then PH_TextTop = PH_TextTop - BHeight
  5873.         if CenterText == 0 then call PrintText(TextLeft + PH_Indent.PH_TextLine, PH_TextTop, Highlight, 'N', TextColor, PH_Width, PH_Text.PH_TextLine)
  5874.         else call CenterText(PrintText(TextLeft + PH_Indent.PH_TextLine, PH_TextTop, Highlight, 'N', TextColor, PH_Width, PH_Text.PH_TextLine), BoxLeft + BoxWidth / 2, 0, 1)
  5875.       end
  5876.       if PH_TextLine ~= PH_LineCount then DailyHLCount = DailyHLCount + 1
  5877.     end
  5878.   end
  5879.  
  5880.   return
  5881. /**/
  5882.  
  5883. /***//*** PrintOption (PO) ***/
  5884. PrintOption:
  5885.   parse arg PO_Location
  5886.  
  5887.   PO_ID = PrintText(BoxLeft + CurveOffset, BoxTop + (BHeight - Height.Extras) * (left(PO_Location, 1) ~= 'T'), Extras, 'N', DO_PrintColor, Width.Extras, DO_Text2Print)
  5888.   if right(PO_Location, 1) == 'C' then call CenterText(PO_ID, BoxLeft + BoxWidth / 2, 0, min(1, BoxWidth/GetWidth(PO_ID)))
  5889.   if right(PO_Location, 1) == 'R' then call RightText(PO_ID, BoxLeft + BoxWidth - 2 * CurveOffset)
  5890.  
  5891.   return PO_ID
  5892. /**/
  5893.  
  5894. /***//*** PrintText (PT) ***/
  5895. PrintText:
  5896.   parse arg PT_Left, PT_Top, PT_FontType, PT_Style, PT_Color, PT_Width, PT_Text
  5897.  
  5898.   if upper(PT_Style) == 'N' then PT_Font = Font.PT_FontType
  5899.   else PT_Font = Bold.PT_FontType
  5900.  
  5901.   if App == 'FW' then do
  5902.     if left(PT_Text, 1) == '"' then PT_Text = '""'PT_Text
  5903.     PT_Top = PT_Top + TextAdj * Height.PT_FontType
  5904.     TEXTBLOCKTYPEPREFS SIZE FSize.PT_FontType WIDTH trunc(PT_Width) COLOR '"'PT_Color'"' FONT PT_Font
  5905.     DRAWTEXTBLOCK 1 trunc(PT_Left, 4) trunc(PT_Top, 4) PT_Text; PT_id = result
  5906.   end
  5907.   else if App == 'PGS' then do
  5908.     DRAWTEXTOBJ PT_Left PT_Top WINDOW winName; PT_id = result
  5909.     SELECTTEXT AT PT_Left PT_Top WINDOW winName
  5910.     BEGINCOMMANDCAPTURE
  5911.       SETLEADING RELATIVE 100
  5912.       SETTYPESIZE FSize.PT_FontType WINDOW winName
  5913.       SETTYPEWIDTH PT_Width WINDOW winName
  5914.       SETFONT PT_Font WINDOW winName
  5915.       SETCOLORSTYLE '"'PT_Color'"' COLORNUMBER 0 FILL TEXT WINDOW winName
  5916.     ENDCOMMANDCAPTURE
  5917.     if pos('"', PT_Text) > 0 then do
  5918.       call WriteFile(Storage'FWCTemp.txt', PT_Text)
  5919.       INSERTTEXT FILE '"'Storage'FWCTemp.txt"' FILTER ASCII WINDOW winName
  5920.     end
  5921.     else INSERT '"'PT_Text'"' WINDOW winName
  5922.   end
  5923.  
  5924.   return PT_id
  5925. /**/
  5926.  
  5927. /***//*** ProcessVariableList (PVL) ***/
  5928. ProcessVariableList:
  5929.   parse arg PVL_DataFile
  5930.  
  5931.   call openv(PVL_DataFile)
  5932.     do until eofv(PVL_DataFile)
  5933.       PVL_Ln = ReadVLn(PVL_DataFile)
  5934.       if PVL_Ln = '' then iterate /* Skip blank lines */
  5935.       PVL_VarName = strip(word(PVL_Ln, 1))
  5936.       PVL_UpperVarName = upper(PVL_VarName)
  5937.       PVL_VarStem = upper(left(PVL_VarName, pos('.', PVL_VarName)))
  5938.       VarNameMaxLn = max(VarNameMaxLn, length(PVL_VarName))
  5939.       if (pos('/* End Pass One', PVL_Ln) > 0) | (PVL_DoHighlights == 1) then do
  5940.         PVL_DoHighlights = 1
  5941.         if left(PVL_Ln, 2) == '/*' then iterate
  5942.         PVL_Month = left(PVL_Ln, 2)
  5943.         if upper(PVL_Month) == 'CA' then PVL_Month = 14
  5944.         MonthCount.PVL_Month = MonthCount.PVL_Month + 1
  5945.         PVL_MonthCount = MonthCount.PVL_Month
  5946.         HighlightData.PVL_Month.PVL_MonthCount = PVL_Ln
  5947.         iterate
  5948.       end
  5949.       if PVL_VarName == 'return' then leave
  5950.       if left(PVL_Ln, 2) == '/*' then iterate
  5951.       if PVL_VarStem == 'IMAGECLASS.' then do
  5952.         ImageClass.ImgClassCount = substr(PVL_VarName, 12)
  5953.         PVL_ImageFile = strip(substr(PVL_Ln, pos("=", PVL_Ln) + 1), 'B', " '"||'"')
  5954.         interpret "ImageFile."ImgClassCount" = PVL_ImageFile"
  5955.         ImgClassCount = ImgClassCount + 1
  5956.         iterate
  5957.       end
  5958.       interpret PVL_Ln
  5959.       if (PVL_VarStem == 'ALTCOLOR.') | (PVL_VarStem == 'BACKGROUND.') |,
  5960.          (PVL_VarStem == 'COLOR.') | (PVL_VarStem == 'LINE.') then do
  5961.         PVL_VariableType = 'Color'
  5962.         if (value(PVL_VarName) == '<'Clear$'>') & (PVL_VarStem ~= 'BACKGROUND.') then do
  5963.           call AddMsg('W', 'Only "Background." variables can be set to <'Clear$'>; 'ColorList.0' used instead.')
  5964.           interpret PVL_VarName' = 'ColorList.0
  5965.         end
  5966.         if (MemberID(value(PVL_VarName), 'ColorList') == -1) then do
  5967.           call AddMsg('W', value(PVL_VarName)' in "'PVL_Ln'"'" can't be found; "ColorList.0" used instead.")
  5968.           PVL_Ln = PVL_VarName' = "'ColorList.0'"'
  5969.         end
  5970.       end
  5971.       else if (PVL_VarStem == 'FONT.') | (PVL_VarStem == 'BOLD.') then PVL_VariableType = 'Font'
  5972.       else if upper(PVL_VarName) == 'DOHIDE' then PVL_VariableType = 'Misc'
  5973.       else if (PVL_VarStem == 'MARGIN.') | (upper(left(PVL_VarName, 2)) == 'DO') |,
  5974.               (upper(PVL_VarName) == 'ORIENTATION') then PVL_VariableType = 'Main'
  5975.       else PVL_VariableType = 'Misc'
  5976.       if (VariableSeq.PVL_UpperVarName == '') & (RD_VariableType == 'Default') then do
  5977.         VariableName.VariableCount = PVL_VarName
  5978.         VariableType.VariableCount = PVL_VariableType
  5979.         VariableSeq.PVL_UpperVarName = VariableCount
  5980.         VariableCount = VariableCount + 1
  5981.       end
  5982.     end
  5983.   call closev(PVL_DataFile)
  5984.  
  5985.   return
  5986. /**/
  5987.  
  5988. /***//*** QuoteIt (PROCEDURE) ***/
  5989. QuoteIt: PROCEDURE
  5990.   parse arg String
  5991.  
  5992.   String = strip(String)
  5993.   if (left(String, 1) == '"') & (right(String, 1) == '"') then return String
  5994.   else if (left(String, 1) == "'") & (right(String, 1) == "'") then return String
  5995.   else if pos("'", String) == 0 then return "'"String"'"
  5996.   else return '"'String'"'
  5997.  
  5998.   return
  5999. /**/
  6000.  
  6001. /***//*** ReadBrowserList (RBL) ***/
  6002. ReadBrowserList:
  6003.   parse arg RBL_FileHandle, RBL_GadIDList, RBL_ItemList, RBL_CurrentItem
  6004.  
  6005.   interpret 'RBL_AlreadyOpen = 'RBL_FileHandle
  6006.   if RBL_AlreadyOpen == 0 then do
  6007.     call ToPIPE(RBL_FileHandle, 'open')
  6008.     if RBL_FileHandle == 'MiscVarReq' then do
  6009.       do RBL_i = 0 to UpdateVarCmds - 1
  6010.         GadID = ToPIPE('MiscVarReq', UpdateVarCmd.RBL_i)
  6011.         interpret 'MiscVarGad.'GadID' = 'UpdateVarNum.RBL_i
  6012.       end
  6013.       UpdateVarCmds = 0
  6014.     end
  6015.     if RBL_CurrentItem ~= '' then call ToPIPE(RBL_FileHandle, 'id 1 s='MemberID(RBL_CurrentItem, RBL_ItemList) + 2)
  6016.     interpret RBL_FileHandle '= 1'
  6017.   end
  6018.   else do
  6019.     if RBL_FileHandle == 'MiscVarReq' then do
  6020.       do RBL_i = 0 to UpdateVarCmds - 1
  6021.         GadID = ToPIPE('MiscVarReq', UpdateVarCmd.RBL_i)
  6022.         interpret 'MiscVarGad.'GadID' = 'UpdateVarNum.RBL_i
  6023.       end
  6024.       UpdateVarCmds = 0
  6025.     end
  6026.     if RBL_CurrentItem ~= '' then call ToPIPE(RBL_FileHandle, 'id 1 s='MemberID(RBL_CurrentItem, RBL_ItemList) + 2)
  6027.     call ToPIPE(RBL_FileHandle, 'id 0 s=64')
  6028.   end
  6029.  
  6030.   do while ~eof(RBL_FileHandle)
  6031.     call ToPIPE(RBL_FileHandle, 'continue')
  6032.     RBL_Result = readln(RBL_FileHandle)
  6033.     parse var RBL_Result . . . . RBL_NodeID
  6034.     RBL_NodeID = strip(RBL_NodeID)
  6035.     interpret 'RBL_ListID = 'RBL_GadIDList'.RBL_NodeID'
  6036.     if pos('gadget', RBL_Result) > 0 then leave
  6037.   end
  6038.   call ToPIPE(RBL_FileHandle, 'id 0 s=128')
  6039.   interpret 'RBL_Entry = 'RBL_ItemList'.'RBL_ListID
  6040.   return RBL_Entry
  6041. /**/
  6042.  
  6043. /***//*** ReadCAGad (PROCEDURE) ***/
  6044. ReadCAGad: PROCEDURE
  6045.   parse arg PipeName, GadgetID
  6046.   call writeln(PipeName, 'id 'GadgetID' read')
  6047.   return readln(PipeName)
  6048. /**/
  6049.  
  6050. /***//*** ReadData (RD) ***/
  6051. ReadData:
  6052.   VariableCount    = 0
  6053.   MainVarCount     = 0
  6054.   MiscVarCount     = 0
  6055.   ColorVarCount    = 0
  6056.   FontVarCount     = 0
  6057.   ImgClassCount    = 0
  6058.   VariableName.    = ''
  6059.   VariableSeq.     = ''
  6060.   RD_Progress      = -1
  6061.   VarNameMaxLn     = 0
  6062.   MonthCount.      = 0
  6063.   PVL_DoHighlights = 0
  6064.   GadSel.          = 0
  6065.   GadDis.          = 0
  6066.   DSR_Sel.         = 0
  6067.   DSR_PSel.        = 0
  6068.   DSR_Dis.         = copies('0', PosnCount + 1)
  6069.   DSR_PDis.        = copies('0', PosnCount + 1)
  6070.  
  6071.   /* Read default variables */
  6072.   call open('Temp', FullCallPath)
  6073.     call seek('Temp', -5000, 'E')
  6074.     Chunk = readch('Temp', 65535)
  6075.     EndPos = pos('VarList:'||'0a'x, Chunk)
  6076.     if EndPos == 0 then do
  6077.       call AddMsg('E', 'Unable to locate default variables.')
  6078.       call CleanUp
  6079.     end
  6080.     RD_VariableFile = substr(Chunk, EndPos + 9)
  6081.   call close('Temp')
  6082.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6083.   RD_VariableType = 'Default'
  6084.   call ProcessVariableList('RD_VariableFile')
  6085.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6086.  
  6087.   if App == 'FW' then do
  6088.     GETSECTIONSETUP Top Bottom Inside Outside
  6089.     parse var result Margin.Top Margin.Bottom Margin.Left Margin.Right
  6090.   end
  6091.   else if App == 'PGS' then do
  6092.     Margin.Top    = 0.5
  6093.     Margin.Bottom = 0.5
  6094.     Margin.Left   = 0.5
  6095.     Margin.Right  = 0.5
  6096.   end
  6097.   do RD_i = 0 to VariableCount - 1
  6098.     Default.RD_i = value(VariableName.RD_i)
  6099.   end
  6100.  
  6101.   /* Read user variables */
  6102.   if PrefsFile ~= 'Default' then do
  6103.     RD_VariableFile = ReadFile(PrefsFile)
  6104.     RD_VariableType = 'User'
  6105.     if RD_VariableFile ~= '' then call ProcessVariableList('RD_VariableFile')
  6106.   end
  6107.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6108.   if HostScreen ~= '' then AppScreen = HostScreen
  6109.  
  6110.   do RD_i = 0 to VariableCount - 1
  6111.     select
  6112.       when VariableType.RD_i == 'Color' then do
  6113.         ColorVarName.ColorVarCount = VariableName.RD_i
  6114.         ColorVarCount = ColorVarCount + 1
  6115.         if ClassAct == 1 then ColorVarList = ColorVarList''VariableName.RD_i'|'
  6116.       end
  6117.       when VariableType.RD_i == 'Font' then do
  6118.         FontVarName.FontVarCount = VariableName.RD_i
  6119.         FontVarCount = FontVarCount + 1
  6120.       end
  6121.       when VariableType.RD_i == 'Main' then do
  6122.         MainVarName.MainVarCount = VariableName.RD_i
  6123.         MainVarCount = MainVarCount + 1
  6124.       end
  6125.       otherwise do
  6126.         MiscVarName.MiscVarCount = VariableName.RD_i
  6127.         MiscVarCount = MiscVarCount + 1
  6128.         if ClassAct == 1 then MiscVarList = MiscVarList''VariableName.RD_i'|'
  6129.       end
  6130.     end
  6131.   end
  6132.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6133.  
  6134.   if ImgClassCount > 0 then do
  6135.     do RD_i = 0 to ImgClassCount - 1
  6136.       MiscVarName.MiscVarCount = 'ImageClass.'ImageClass.RD_i
  6137.       MiscVarCount = MiscVarCount + 1
  6138.       if ClassAct == 1 then MiscVarList = MiscVarList''MiscVarName.MiscVarCount'|'
  6139.     end
  6140.   end
  6141.  
  6142.   MainVarName.COUNT  = MainVarCount
  6143.   MiscVarName.COUNT  = MiscVarCount
  6144.   ColorVarName.COUNT = ColorVarCount
  6145.   FontVarName.COUNT  = FontVarCount
  6146.   ImageClass.COUNT   = ImgClassCount
  6147.  
  6148.   CurrentColorName   = ColorVarName.0
  6149.   CurrentFontName    = FontVarName.0
  6150.   CurrentMiscName    = MiscVarName.0
  6151.   if upper(left(CurrentMiscName, 11)) == 'IMAGECLASS.' then do
  6152.     IC = MemberID(upper(substr(CurrentMiscName, 12)), 'ImageClass')
  6153.     VarVal = ImageFile.IC
  6154.   end
  6155.   else VarVal = Value(CurrentMiscName)
  6156.  
  6157.   if upper(Orientation) == 'WIDE' then OrientChoice = 0
  6158.   else OrientChoice = 1
  6159.  
  6160.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6161.   if (exists(SunCalcPath'suncalc')) & (~exists(Storage'suncalc')) then address command 'copy 'SunCalcPath'suncalc 'Storage
  6162.  
  6163.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6164.   if (exists(GfxAppPath''GfxApp)) & (~exists(Storage''GfxApp)) then address command 'copy 'GfxAppPath''GfxApp' 'Storage
  6165.   if ~exists(Storage''GfxApp) then do
  6166.     GfxDisable = 1
  6167.     DoImages = 0
  6168.   end
  6169.   else GfxDisable = 0
  6170.  
  6171.   if PhaseLib ~= 1 then DoPhases = 0
  6172.  
  6173.   return
  6174. /**/
  6175.  
  6176. /***//*** ReadFile (PROCEDURE) ***/
  6177. ReadFile: PROCEDURE
  6178.   parse arg file
  6179.  
  6180.   if open('Temp', file) then do
  6181.     val = strip(readch('Temp', 65535), 'B', ' '||'0a'x)
  6182.     call close('Temp')
  6183.   end
  6184.   else val = ''
  6185.   return val
  6186. /**/
  6187.  
  6188. /***//*** ReadToEOL (PROCEDURE) ***/
  6189. ReadToEOL: PROCEDURE
  6190.   parse arg Start, Var
  6191.  
  6192.   if Start == 0 then return ''
  6193.  
  6194.   EOL = pos('0a'x, Var, Start)
  6195.   if EOL == 0 then EOL = length(Var) + 1
  6196.  
  6197.   return substr(Var, Start, EOL - Start)
  6198. /**/
  6199.  
  6200. /***//*** ReplaceString (RS) ***/
  6201. ReplaceString: PROCEDURE
  6202.   parse arg old, new, string
  6203.  
  6204.   if pos(old, string) > 0 then do
  6205.     parse var string begin(old)end
  6206.     return begin || new || ReplaceString(old, new, end)
  6207.   end
  6208.  
  6209.   return string
  6210. /**/
  6211.  
  6212. /***//*** RightText (RT) ***/
  6213. RightText:
  6214.   parse arg RT_id, RT_RightEdge
  6215.  
  6216.   if App = 'FW' then do
  6217.     GETOBJECTCOORDS RT_id; Parse Var result . . RT_Text.Bottom RT_Text.Width RT_Text.Height
  6218.     RT_Text.Left = RT_RightEdge - RT_Text.Width
  6219.     SETOBJECTCOORDS RT_id 1 RT_Text.Left RT_Text.Bottom RT_Text.Width RT_Text.Height
  6220.   end
  6221.   else if App == 'PGS' then do
  6222.     GETTEXTOBJ POSITION RT_Text OBJECTID RT_id WINDOW winName
  6223.     RT_Text.Width = RT_Text.Right - RT_Text.Left
  6224.     RT_Text.Left = RT_RightEdge - RT_Text.Width
  6225.     EDITTEXTOBJ POSITION RT_Text.Left RT_Text.Top (RT_Text.Left + RT_Text.Width) RT_Text.Bottom OBJECTID RT_id WINDOW winName
  6226.   end
  6227.   return RT_id
  6228. /**/
  6229.  
  6230. /***//*** SaveVariable (SV) ***/
  6231. SaveVariable:
  6232.   parse arg SV_OutFile, SV_Variable, SV_Value
  6233.  
  6234.   SV_Cmd = SV_Variable' = 'SV_Value
  6235.   call WriteLn(SV_OutFile, SV_Cmd)
  6236.   interpret SV_Cmd
  6237.  
  6238.   return
  6239. /**/
  6240.  
  6241. /***//*** SetFill (SF) ***/
  6242. SetFill:
  6243.   parse arg SF_ID, SF_StrokeColor, SF_FillColor
  6244.  
  6245.   BEGINCOMMANDCAPTURE
  6246.     SETSTROKEWEIGHT '0.3pt' STROKENUMBER 0 OBJECT OBJECTID SF_ID WINDOW winName
  6247.     SETCOLORSTYLE '"'SF_StrokeColor'"' STROKENUMBER 0 OBJECT OBJECTID SF_ID WINDOW winName
  6248.     FILLED 'ON'
  6249.     SETCOLORSTYLE '"'SF_FillColor'"' FILL OBJECT OBJECTID SF_ID WINDOW winName
  6250.   ENDCOMMANDCAPTURE
  6251.   return
  6252. /**/
  6253.  
  6254. /***//*** SetHighlights (SH) ***/
  6255. SetHighlights:
  6256. /* The algorithm for calculating Easter is due to J.-M. Oudin (1940) and is        */
  6257. /* reprinted in the Explanatory Supplement to the Astronomical Almanac, ed. P. K.  */
  6258. /* Seidelmann (1992). See Chapter 12, "Calendars", by L. E. Doggett.               */
  6259. /*                                                                                 */
  6260. /* I obtained the algorithm from the US Naval Observatory web site                 */
  6261.  
  6262.   SettingHighlights = 1
  6263.   if EasterKnown ~= 1 then do
  6264.     SH_century = trunc(Year / 100)
  6265.     SH_n = trunc(Year - 19 * trunc(Year / 19))
  6266.     SH_k = trunc((SH_century - 17) / 25)
  6267.     SH_i = SH_century - trunc(SH_century / 4) - trunc((SH_century - SH_k) / 3) + 19 * SH_n + 15
  6268.     SH_i = SH_i - 30 * trunc(SH_i / 30)
  6269.     SH_i = SH_i - trunc(SH_i / 28) * (1 - trunc(SH_i / 28) * trunc(29 / (SH_i + 1)) * trunc((21 - SH_n) / 11))
  6270.     SH_j = Year + trunc(Year / 4) + SH_i + 2 - SH_century + trunc(SH_century / 4)
  6271.     SH_j = SH_j - 7 * trunc(SH_j / 7)
  6272.     SH_l = SH_i - SH_j
  6273.     SH_EasterMonth  = 3 + trunc((SH_l + 40 ) / 44)
  6274.     SH_EasterDay    = SH_l + 28 - 31 * trunc(SH_EasterMonth / 4)
  6275.     EasterSerial = DateInfo('I', Year'0'SH_EasterMonth''right(SH_EasterDay, 2, '0'), 'S')
  6276.     EasterKnown  = 1
  6277.   end
  6278.   Highlight. = ''
  6279.   Image.     = ''
  6280.  
  6281.   if PrefsFile ~= 'Default' then do
  6282.     call open('DataFile', PrefsFile)
  6283.     do forever
  6284.       if eof('DataFile') then leave
  6285.       if pos('/* End Pass One', readln('DataFile')) > 0 then do
  6286.         do until eof('DataFile')
  6287.           SH_Ln = strip(ReadLn('DataFile'))
  6288.           if right(SH_Ln, 2) == '*/' then SH_Ln = left(SH_Ln, lastpos('/*', SH_Ln) - 1)
  6289.           SH_Ln2 = left(SH_Ln, 2)
  6290.           if upper(left(SH_Ln, 14)) == 'CALCULATEEDATE' then interpret 'call 'SH_Ln
  6291.           if (SH_Ln2 == Mn) | (SH_Ln2 == '13') then do
  6292.             select
  6293.               when upper(substr(SH_Ln, 3, 13)) == 'CALCULATEDATE' then interpret 'call 'substr(SH_Ln, 3)
  6294.               when upper(substr(SH_Ln, 3, 9)) == 'HIGHLIGHT' then call AssignHighlight(substr(SH_Ln, 3))
  6295.               when upper(substr(SH_Ln, 3, 5)) == 'IMAGE' then call AssignImage(substr(SH_Ln, 3))
  6296.               when upper(substr(SH_Ln, 3, 14)) == 'CALCULATEIMAGE' then interpret 'call 'substr(SH_Ln, 3)
  6297.               otherwise do
  6298.                 call AddMsg('W', 'Check the keyword in the following line of your preferences file:')
  6299.                 call AddMsg('W', '  'SH_Ln)
  6300.                 ListHighlightData = 1
  6301.               end
  6302.             end
  6303.           end
  6304.         end
  6305.       end
  6306.     end
  6307.     call close('DataFile')
  6308.   end
  6309.  
  6310.   SettingHighlights = 0
  6311. return
  6312. /**/
  6313.  
  6314. /***//*** Syntax () ***/
  6315. Syntax:
  6316.   if DoingCleanup == 1 then return
  6317.   signal off syntax
  6318.  
  6319.   ErrorLine  = SIGL
  6320.   SourceLine = strip(SourceLine(ErrorLine))
  6321.  
  6322.   call AddMsg('E', 'Error 'RC' ('errortext(RC)')')
  6323.   call AddMsg('E', 'Line 'ErrorLine': 'SourceLine)
  6324.   call AddMsg('E', ParseVariables(SourceLine))
  6325.  
  6326.   call Cleanup
  6327.   exit
  6328. /**/
  6329.  
  6330. /***//*** ToPIPE (TP) ***/
  6331. ToPIPE:
  6332.   parse arg PipeName, TP_CMD
  6333.  
  6334.   call writeln(PipeName,' 'TP_CMD)
  6335.   TP_Response=readln(PipeName)
  6336.  
  6337.   parse var TP_Response TP_Response1 TP_Response2 .
  6338.  
  6339.   if TP_Response1 == 'ok' then return(TP_Response2)
  6340.   if TP_Response == '' then TP_Response = 'Blank line'
  6341.   call AddMsg('E', 'Line : 'SIGL)
  6342.   call AddMsg('E', PipeName' error: 'TP_Response)
  6343.   call AddMsg('E', 'Returned from: 'TP_CMD)
  6344.   call Cleanup
  6345. /**/
  6346.  
  6347. /***//*** VIO Routines () ***/
  6348. /***//** OpenV() **/
  6349. OpenV:
  6350.   parse arg VIO_Variable
  6351.  
  6352.   if Open.VIO_Variable ~= 1 then do
  6353.     if symbol(VIO_Variable) == 'LIT' then interpret VIO_Variable' = ""'
  6354.     Open.VIO_Variable = 1
  6355.     Pointer.VIO_Variable = 1
  6356.     EOF.VIO_Variable = 0
  6357.     return 1
  6358.   end
  6359.   else return 0
  6360. /**/
  6361.  
  6362. /***//** CloseV() **/
  6363. CloseV:
  6364.   parse arg VIO_Variable
  6365.  
  6366.   If Open.VIO_Variable == 0 then return 0
  6367.   Open.VIO_Variable = 0
  6368.   return 1
  6369. /**/
  6370.  
  6371. /***//** SeekV() **/
  6372. SeekV:
  6373.   parse arg VIO_Variable, VIO_Offset, VIO_Anchor
  6374.  
  6375.   if Open.VIO_Variable == 1 then do
  6376.     VIO_Anchor = upper(left(VIO_Anchor, 1))
  6377.  
  6378.     VIO_Value = Value(VIO_Variable)
  6379.     select
  6380.       when VIO_Anchor == 'B' then Pointer.VIO_Variable = VIO_Offset
  6381.       when VIO_Anchor == 'E' then Pointer.VIO_Variable = length(VIO_Value) + VIO_Offset
  6382.       otherwise Pointer.VIO_Variable = Pointer.VIO_Variable + VIO_Offset
  6383.     end
  6384.  
  6385.     if Pointer.VIO_Variable > length(VIO_Value) then Pointer.VIO_Variable = length(VIO_Value) + 1
  6386.     if Pointer.VIO_Variable == 0 then Pointer.VIO_Variable = 1
  6387.     return Pointer.VIO_Variable
  6388.   end
  6389.   else return 0
  6390. /**/
  6391.  
  6392. /***//** ReadVCh() **/
  6393. ReadVCh:
  6394.   parse arg VIO_Variable, VIO_Length
  6395.  
  6396.   if VIO_Length == '' then VIO_Length = 1
  6397.   if Open.VIO_Variable == 1 then do
  6398.     if EOF.VIO_Variable == 0 then do
  6399.       VIO_Value = Value(VIO_Variable)
  6400.       VIO_Length = min(VIO_Length, length(VIO_Value) - Pointer.VIO_Variable)
  6401.       VIO_Ret = substr(VIO_Value, Pointer.VIO_Variable, VIO_Length)
  6402.       Pointer.VIO_Variable = Pointer.VIO_Variable + VIO_Length
  6403.       if Pointer.VIO_Variable > length(VIO_Value) then EOF.VIO_Variable = 1
  6404.       else EOF.VIO_Variable = 0
  6405.     end
  6406.     else VIO_Ret = ''
  6407.   end
  6408.   else VIO_Ret = ''
  6409.  
  6410.   return VIO_Ret
  6411. /**/
  6412.  
  6413. /***//** ReadVLn(RV) **/
  6414. ReadVLn:
  6415.   parse arg VIO_Variable, VIO_Count, VIO_SepChar
  6416.  
  6417.   if VIO_Count == '' then VIO_Count = 1
  6418.   if VIO_SepChar == '' then VIO_SepChar = '0a'x
  6419.  
  6420.   if Open.VIO_Variable == 1 then do
  6421.     VIO_Value = Value(VIO_Variable)
  6422.     VIO_Ret   = ''
  6423.     do VIO_i = 1 to VIO_Count
  6424.       VIO_LF = pos('0a'x, VIO_Value, Pointer.VIO_Variable)
  6425.       if VIO_LF > 0 then do
  6426.         VIO_Ret = VIO_Ret''substr(VIO_Value, Pointer.VIO_Variable, VIO_LF - Pointer.VIO_Variable)
  6427.         Pointer.VIO_Variable = VIO_LF + 1
  6428.         if VIO_LF = length(VIO_Value) then EOF.VIO_Variable = 1
  6429.         else EOF.VIO_Variable = 0
  6430.       end
  6431.       else do
  6432.         if Pointer.VIO_Variable < length(VIO_Value) then do
  6433.           VIO_Ret = VIO_Ret''substr(VIO_Value, Pointer.VIO_Variable)
  6434.           Pointer.VIO_Variable = length(VIO_Value) + 1
  6435.           EOF.VIO_Variable = 1
  6436.         end
  6437.       end
  6438.       if EOF.VIO_Variable == 1 then leave
  6439.       if VIO_i ~= VIO_Count then VIO_Ret = VIO_Ret''VIO_SepChar
  6440.     end
  6441.   end
  6442.   else VIO_Ret = ''
  6443.  
  6444.   return VIO_Ret
  6445. /**/
  6446.  
  6447. /***//** WriteVCh() **/
  6448. WriteVCh:
  6449.   parse arg VIO_Variable, VIO_String, VIO_Option
  6450.  
  6451.   VIO_Value  = Value(VIO_Variable)
  6452.   VIO_Option = upper(left(VIO_Option, 1))
  6453.   VIO_Length = length(VIO_Value)
  6454.   if VIO_Option == 'C' then do
  6455.     VIO_Value = Insert(VIO_String, VIO_Value, Pointer.VIO_Variable - 1)
  6456.     Pointer.VIO_Variable = Pointer.VIO_Variable + length(VIO_String)
  6457.   end
  6458.   else if VIO_Option == 'B' then do
  6459.     VIO_Value = VIO_String''VIO_Value
  6460.     Pointer.VIO_Variable = length(VIO_String) + 1
  6461.   end
  6462.   else do
  6463.     VIO_Value = VIO_Value''VIO_String
  6464.     Pointer.VIO_Variable = length(VIO_Value)
  6465.   end
  6466.   interpret VIO_Variable'= VIO_Value'
  6467.   if length(VIO_Value) = VIO_Length + length(VIO_String) then VIO_Ret = length(VIO_String)
  6468.   else VIO_Ret = 0
  6469.  
  6470.   return VIO_Ret
  6471. /**/
  6472.  
  6473. /***//** WriteVLn() **/
  6474. WriteVLn:
  6475.   parse arg VIO_Variable, VIO_String, VIO_Option
  6476.  
  6477.   return WriteVCh(VIO_Variable, VIO_String||'0a'x, VIO_Option)
  6478. /**/
  6479.  
  6480. /***//** EOFV() **/
  6481. EOFV:
  6482.   parse arg VIO_Variable
  6483.  
  6484.   if Open.VIO_Variable == 1 then return EOF.VIO_Variable
  6485.   else return 1
  6486. /**/
  6487. /**/
  6488.  
  6489. /***//*** WriteData (WD) ***/
  6490. WriteData:
  6491.   WD_FileOpen      = 0
  6492.   WD_MsgWritten    = 0
  6493.   WD_SepWritten    = 0
  6494.  
  6495.   /* Write non-imageclass variables */
  6496.   do WD_i = 0 to VariableCount - 1
  6497.     if value(VariableName.WD_i) ~= Default.WD_i then do
  6498.       WD_Value = Value(VariableName.WD_i)
  6499.       if (datatype(WD_Value) == 'CHAR') then do
  6500.         if pos("'", WD_Value) ~= 0 then WD_Value = '"'WD_Value'"'
  6501.         else WD_Value = "'"WD_Value"'"
  6502.       end
  6503.       call WriteDataLine(VariableName.WD_i' = 'WD_Value)
  6504.     end
  6505.   end
  6506.  
  6507.   /* Write imageclass variables */
  6508.   do WD_i = 0 to ImgClassCount - 1
  6509.     if ImageFile.WD_i ~= ScriptDir'Images/' then call WriteDataLine('ImageClass.'ImageClass.WD_i' = 'QuoteIt(ImageFile.WD_i))
  6510.   end
  6511.  
  6512.   /* Write highlight variables */
  6513.   do WD_i = 1 to 14
  6514.     WD_Month = right(WD_i, 2, '0')
  6515.     WD_MonthCount = MonthCount.WD_Month
  6516.     if WD_MonthCount > 0 then do
  6517.       do WD_j = 1 to WD_MonthCount
  6518.         if symbol('HighlightData.WD_Month.WD_j') == 'VAR' then do
  6519.           if WD_SepWritten == 0 then do
  6520.             call WriteDataLine('/* End Pass One - DO NOT DELETE THIS LINE!!! */')
  6521.             WD_SepWritten = 1
  6522.           end
  6523.           call WriteDataLine(HighlightData.WD_Month.WD_j)
  6524.         end
  6525.       end
  6526.     end
  6527.   end
  6528.  
  6529.   call close('DataFile')
  6530.  
  6531.   return
  6532.  
  6533. WriteDataLine:
  6534.   parse arg WDL_Data
  6535.  
  6536.   if WD_FileOpen == 0 then do
  6537.     if PrefsFile == 'Default' then do
  6538.       if ClassAct == 1 then WDL_File = CAGetFile('CA', GetFileDataGad, SelectPrefs$, ScriptDir'FWCalendar.prefs')
  6539.       else WDL_File = bguifilereq(ScriptDir'FWCalendar.prefs', SelectPrefs$)
  6540.       if WDL_File ~= '' then do
  6541.         WD_FileOpen = open('DataFile', WDL_File, 'W')
  6542.         if WD_FileOpen ~= 0 then do
  6543.           PrefsFile = WDL_File
  6544.           call WriteFile('ENV:FWCalendar', PrefsFile, 'B')
  6545.         end
  6546.         else call AddMsg('W', "Couldn't open selected data file ("WDL_File")")
  6547.       end
  6548.     end
  6549.     else WD_FileOpen = open('DataFile', PrefsFile, 'W')
  6550.     if WD_FileOpen ~= 0 then call writeln('DataFile', '/* Dataversion 'word(sourceline(4), 3)' */')
  6551.   end
  6552.   if WD_FileOpen ~= 0 then call writeln('DataFile', WDL_Data)
  6553.   else do
  6554.     if WD_MsgWritten == 0 then do
  6555.       WD_MsgWritten = 1
  6556.       call AddMsg('W', 'Unable to write to preference file.')
  6557.     end
  6558.   end
  6559.   return
  6560. /**/
  6561.  
  6562. /***//*** WriteFile (PROCEDURE) ***/
  6563. WriteFile: PROCEDURE
  6564.   parse arg file, var, which
  6565.  
  6566.   if open('Temp', file, 'W') then do
  6567.     success = writech('Temp', var)
  6568.     call close('Temp')
  6569.   end
  6570.   if (upper(which) == 'B') & (upper(left(file, 4)) == 'ENV:') then call WriteFile('ENVARC:'substr(file, 5), var)
  6571.  
  6572.   return success
  6573. /**/
  6574.  
  6575. /***//*** InitializeVariables (IV) ***/
  6576. InitializeVariables:
  6577.   esc               = "1B"x
  6578.   FSize.            = 10
  6579.   GenCalCount       = 22
  6580.   HighlightCount    = 0
  6581.   ImageCount        = 0
  6582.   ImageHeight.      = 0
  6583.   ImageType.        = ''
  6584.   ImageWidth.       = 0
  6585.   MoonPhase.        = ''
  6586.   UserPrefs         = ''
  6587.   Width.            = 100
  6588.   Spc               =' '
  6589.   NormalWidth.Spc   = 0
  6590.   BoldWidth.Spc     = 0
  6591.   ColorW            = 80
  6592.   ColorH            = 10
  6593.  
  6594.   PGSFilter.     = ''
  6595.   PGSFilter.ILBM = 'IFFILBM'
  6596.   PGSFilter.JFIF = 'JPEG'
  6597.   PGSFilter.POST = 'IllustratorEPS'
  6598.  
  6599.   GfxCmd.Visage      = '%s info'
  6600.   GfxTemplate.Visage = '. "0a"x . ImgDT ImgWidth "x" ImgHeight "x" .'
  6601.  
  6602.   GfxCmd.ImageDTInfo      = '%s'
  6603.   GfxTemplate.ImageDTInfo = 'ImgDT "-" ImgWidth "x" ImgHeight "x" .'
  6604.  
  6605.   GfxCmd.PicSize      = '%s "%t %w %h"'
  6606.   GfxTemplate.PicSize = 'ImgDT ImgWidth ImgHeight "0a"x'
  6607.  
  6608.   GroupCount     = 4
  6609.  
  6610.   PhasesPosn     = 1
  6611.   WeeknumberPosn = 2
  6612.   JulianPosn     = 3
  6613.   JulianLeftPosn = 4
  6614.   BothJPosn      = 5
  6615.   SunrisePosn    = 6
  6616.   SunsetPosn     = 7
  6617.   BothSPosn      = 8
  6618.   HistoryPosn    = 9
  6619.   RandomPosn     = 10
  6620.   PosnCount      = 10
  6621.  
  6622.   MXPair.1       = '11111 0011000000 0000100000'
  6623.   MXPair.2       = '11111 0000011000 0000000100'
  6624.   MXPair.3       = '11100 1111111100 0000000011'
  6625.   MXPairCount    = 3
  6626.  
  6627.   Do.1  = 'Phases'
  6628.   Do.2  = 'Weeknumber'
  6629.   Do.3  = 'Julian'
  6630.   Do.4  = 'JulianLeft'
  6631.   Do.5  = 'BothJ'
  6632.   Do.6  = 'Sunrise'
  6633.   Do.7  = 'Sunset'
  6634.   Do.8  = 'BothS'
  6635.   Do.9  = 'History'
  6636.   Do.10 = 'Random'
  6637.  
  6638.   if App == 'FW' then do
  6639.     DefaultFont = 'SoftSans'
  6640.     DefaultBold = 'SoftSans_Bold'
  6641.   end
  6642.   else if App == 'PGS' then do
  6643.     DefaultFont = 'PageStream-Normal'
  6644.     DefaultBold = 'PageStream-Normal'
  6645.   end
  6646.  
  6647.   Date      = 0
  6648.   Weekday   = 1
  6649.   Header    = 2
  6650.   MiniCal   = 3
  6651.   FYMiniCal = 4
  6652.   Highlight = 5
  6653.   Extras    = 6
  6654.   SubHeader = 7
  6655.   FontTypes = 7
  6656.  
  6657.   D.0 = 'Sunday'
  6658.   D.1 = 'Monday'
  6659.   D.2 = 'Tuesday'
  6660.   D.3 = 'Wednesday'
  6661.   D.4 = 'Thursday'
  6662.   D.5 = 'Friday'
  6663.   D.6 = 'Saturday'
  6664.  
  6665.   MonthLength.1  = 31
  6666.   MonthLength.2  = 28
  6667.   MonthLength.3  = 31
  6668.   MonthLength.4  = 30
  6669.   MonthLength.5  = 31
  6670.   MonthLength.6  = 30
  6671.   MonthLength.7  = 31
  6672.   MonthLength.8  = 31
  6673.   MonthLength.9  = 30
  6674.   MonthLength.10 = 31
  6675.   MonthLength.11 = 30
  6676.   MonthLength.12 = 31
  6677.  
  6678.   Month.1  = January$
  6679.   Month.2  = February$
  6680.   Month.3  = March$
  6681.   Month.4  = April$
  6682.   Month.5  = May$
  6683.   Month.6  = June$
  6684.   Month.7  = July$
  6685.   Month.8  = August$
  6686.   Month.9  = September$
  6687.   Month.10 = October$
  6688.   Month.11 = November$
  6689.   Month.12 = December$
  6690.  
  6691.   return
  6692. /**/
  6693.  
  6694. /***//*** SetVariables ***/
  6695. SetVariables:
  6696.   CNotice     = 'Created w/ FWCalendar © Ron Goertz'
  6697.   FSize.4pt   = 4
  6698.   Font.4pt    = DefaultFont
  6699.  
  6700.   DoJulian       = upper(DoJulian)
  6701.   DoJulianLeft   = upper(DoJulianLeft)
  6702.   CalendarBorder = CalendarBorder / 100
  6703.   CalendarShadow = CalendarShadow / 100
  6704.   CornerRadius   = CornerRadius / 100
  6705.   DateOffset     = DateOffset / 100
  6706.   HeaderLoc      = HeaderLoc / 100
  6707.   HeaderSize     = HeaderSize / 100
  6708.   MagnifyExtras  = MagnifyExtras / 100
  6709.   MaxImgHeight   = MaxImgHeight / 100
  6710.   MaxImgWidth    = MaxImgWidth / 100
  6711.   MiniCalHeight  = MiniCalHeight / 100
  6712.   MiniCalWidth   = MiniCalWidth / 100
  6713.   MoonRadius     = MoonRadius / 100
  6714.   ShiftLMini     = ShiftLMini / 720
  6715.   ShiftRMini     = ShiftRMini / 720
  6716.   StretchDateH   = StretchDateH / 100
  6717.   StretchDateW   = StretchDateW / 100
  6718.   SubHeaderLoc   = SubHeaderLoc / 100
  6719.   SubHeaderSize  = SubHeaderSize / 100
  6720.   TextAdj        = TextAdj / 100
  6721.   TTextArea      = TTextArea / 100
  6722.   WeekdaySize    = WeekdaySize / 100
  6723.   WTextArea      = WTextArea / 100
  6724.  
  6725.   if (PhaseLib ~= 1) & (DoPhases ~= 0) then do
  6726.     call AddMsg('W', 'date.library or rexxmathlib.library are required to calculate the moon phases.')
  6727.     DoPhases = 0
  6728.   end
  6729.  
  6730.   if App == 'FW' then do
  6731.     TextBase = TextAdj
  6732.     do i = 0 to FontTypes
  6733.       if Font.i == FilePart(Font.i) then Font.i = CurrentDir'FWFonts/SWOLFonts/'Font.i
  6734.       if ~exists(Font.i) then do
  6735.         call AddMsg('W', FilePart(Font.i)" can't be found; "DefaultFont" used instead.")
  6736.         Font.i = DefaultFont
  6737.       end
  6738.     end
  6739.     if Bold.MiniCal == FilePart(Bold.MiniCal) then Bold.MiniCal = CurrentDir'FWFonts/SWOLFonts/'Bold.MiniCal
  6740.     if ~exists(Bold.MiniCal) then do
  6741.       call AddMsg('W', FilePart(Bold.MiniCal)" can't be found; "DefaultBold" used instead.")
  6742.       Bold.MiniCal = DefaultBold
  6743.     end
  6744.     if Bold.FYMiniCal == FilePart(Bold.FYMiniCal) then Bold.FYMiniCal = CurrentDir'FWFonts/SWOLFonts/'Bold.FYMiniCal
  6745.     if ~exists(Bold.FYMiniCal) then do
  6746.       call AddMsg('W', FilePart(Bold.FYMiniCal)" can't be found; "DefaultBold" used instead.")
  6747.       Bold.FYMiniCal = DefaultBold
  6748.     end
  6749.     PAGESETUP ORIENT Orientation
  6750.     if upper(Orientation) == 'WIDE' then TextArea = WTextArea
  6751.     else TextArea = TTextArea
  6752.  
  6753.     GETDISPLAYPREFS Measure; UserPrefs = 'DISPLAYPREFS Measure 'result
  6754.     DISPLAYPREFS Measure Inches
  6755.     SECTIONSETUP TOP Margin.Top BOTTOM Margin.Bottom INSIDE Margin.Left OUTSIDE Margin.Right
  6756.     GETPAGESETUP Width Height
  6757.     parse var result FullWidth FullHeight
  6758.   end
  6759.   else if App = 'PGS' then do
  6760.     TextBase = 1
  6761.     do i = 0 to FontTypes
  6762.       do j = 0 to FontList.COUNT - 1
  6763.         if upper(Font.i) == upper(FontList.j) then leave
  6764.       end
  6765.       if j == FontList.COUNT then do
  6766.         call AddMsg('W', Font.i" can't be found; "DefaultFont" used instead.")
  6767.         Font.i = DefaultFont
  6768.       end
  6769.     end
  6770.     do j = 0 to FontList.COUNT - 1
  6771.       if upper(Bold.MiniCal) == upper(FontList.j) then leave
  6772.     end
  6773.     if j == FontList.COUNT then do
  6774.       call AddMsg('W', Bold.MiniCal" can't be found; "DefaultBold" used instead.")
  6775.       Bold.MiniCal = DefaultBold
  6776.     end
  6777.     do j = 0 to FontList.COUNT - 1
  6778.       if upper(Bold.FYMiniCal) == upper(FontList.j) then leave
  6779.     end
  6780.     if j == FontList.COUNT then do
  6781.       call AddMsg('W', Bold.FYMiniCal" can't be found; "DefaultBold" used instead.")
  6782.       Bold.FYMiniCal = DefaultBold
  6783.     end
  6784.  
  6785.     if upper(Orientation) == 'WIDE' then do
  6786.       TextArea = WTextArea
  6787.       Orientation = 'LANDSCAPE'
  6788.     end
  6789.     else do
  6790.       TextArea = TTextArea
  6791.       Orientation = 'PORTRAIT'
  6792.     end
  6793.  
  6794.     if CalType == 1 then DocName = '"'EnteredYear''Mn''Calendar$'"'
  6795.     else if CalType == 2 then DocName = '"'EnteredYear''Calendars$'"'
  6796.     else DocName = '"'EnteredYear''Calendar$'"'
  6797.     PageName = '"FWCalendar by Ron Goertz"'
  6798.     NEWDOCUMENT DocName
  6799.     NEWMASTERPAGE PageName PageWidth PageHeight SINGLE Orientation
  6800.     SETMARGINGUIDES Margin.Left Margin.Right Margin.Top Margin.Bottom MASTERPAGE PageName
  6801.     SETDIMENSIONS PageWidth PageHeight SINGLE Orientation MASTERPAGE PageName
  6802.     SETCOLUMNGUIDES 0 0 MASTERPAGE PageName
  6803.     SETDOCUMENTSTATUS unchanged DOCUMENT DocName
  6804.     OPENWINDOW '"View 1"' DOCUMENT DocName PAGE 1
  6805.     GETMEASUREMENTS COORDINATE stemc RELATIVE rel TEXT tex FROM fro
  6806.     UserPrefs = 'SETMEASUREMENTS COORDINATE 'stemc.horizontal stemc.vertical' RELATIVE 'rel' TEXT 'tex' FROM 'fro
  6807.     SETMEASUREMENTS COORDINATE Inches Sameas RELATIVE Sameas TEXT Points FROM Page
  6808.     GETMARGINGUIDES temp MASTERPAGE PageName
  6809.     if rc == 0 then do
  6810.       Margin.Left   = temp.inside
  6811.       Margin.Right  = temp.outside
  6812.       Margin.Top    = temp.top
  6813.       Margin.Bottom = temp.bottom
  6814.     end
  6815.     GETDIMENSIONS temp MASTERPAGE PageName
  6816.     CmdSuccess = rc
  6817.     if Orientation = 'LANDSCAPE' then do
  6818.       if CmdSuccess == 0 then do
  6819.         FullWidth  = temp.height
  6820.         FullHeight = temp.width
  6821.       end
  6822.       else do
  6823.         FullWidth  = PageHeight
  6824.         FullHeight = PageWidth
  6825.       end
  6826.     end
  6827.     else do
  6828.       if CmdSuccess == 0 then do
  6829.         FullWidth  = temp.width
  6830.         FullHeight = temp.height
  6831.       end
  6832.       else do
  6833.         FullWidth  = PageWidth
  6834.         FullHeight = PageHeight
  6835.       end
  6836.     end
  6837.     CURRENTWINDOW; winName = '"'RESULT'"'
  6838.   end
  6839.  
  6840.   if App == 'FW' then do
  6841.     VIEW 20
  6842.   end
  6843.   else if App == 'PGS' then do
  6844.     if DoHide == 1 then HIDEWINDOW
  6845.     else DISPLAY SCALE 25
  6846.     REFRESH OFF
  6847.   end
  6848.  
  6849.   if CalType == 1 then do
  6850.     EventCount = GenCalCount + MonthLength.Month + DoMiniCals * (MonthLength.NextMonth + MonthLength.PrevMonth + 4)
  6851.     Gen$ = BuildString(GeneratingM$, GenMVars)
  6852.   end
  6853.   else if CalType == 2 then do
  6854.     if EndMonth < Month then EndMonth = EndMonth + 12
  6855.     MonthCount = EndMonth - Month + 1
  6856.     EventCount = 7 + (MonthCount * 54) + DoMiniCals * (MonthCount * 62)
  6857.     Gen$ = BuildString(GeneratingY$, GenYVars)
  6858.   end
  6859.   else do
  6860.     EventCount = 365 + 24
  6861.     Gen$ = BuildString(GeneratingY$, GenYVars)
  6862.   end
  6863.   Req = OpenBusy(Gen$, EventCount)
  6864.  
  6865.   PrintWidth  = FullWidth - Margin.Left - Margin.Right
  6866.   PrintHeight = FullHeight - Margin.Top - Margin.Bottom
  6867.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6868.  
  6869.   if CalType < 3 then do
  6870.     Height.4pt = GetHeight(4pt)
  6871.  
  6872.     if ((PrintHeight - Height.4pt - (TextArea * PrintHeight))/5 * 8) >= 4 then do
  6873.       DoCopyright = 1
  6874.       PrintHeight = PrintHeight - Height.4pt
  6875.     end
  6876.     else DoCopyright = 0
  6877.  
  6878.     CalendarBorder  = CalendarBorder * PrintWidth
  6879.     CalendarShadow  = CalendarShadow * PrintWidth
  6880.     PrintWidth      = PrintWidth - 2 * CalendarBorder - CalendarShadow
  6881.     PrintHeight     = PrintHeight - 2 * CalendarBorder - CalendarShadow
  6882.     Margin.Left     = Margin.Left + CalendarBorder
  6883.  
  6884.     BoxWidth        = PrintWidth/(WeekdayCount + 1)
  6885.     CalRight        = Margin.Left + BoxWidth * (WeekdayCount + 1)
  6886.  
  6887.     TextArea        = TextArea * PrintHeight
  6888.     CalTop          = TextArea + Margin.Top + CalendarBorder
  6889.     BoxHeight       = (PrintHeight - TextArea)/5
  6890.     MoonRadius      = BoxHeight * MoonRadius
  6891.     CRadius         = CornerRadius * BoxWidth
  6892.     CurveOffset     = DateOffset * BoxWidth + CRadius * .25
  6893.     DateOffset      = DateOffset * BoxWidth
  6894.     MiniCalHeight   = TextArea * MiniCalHeight
  6895.     MiniCalWidth    = MiniCalHeight * MiniCalWidth
  6896.  
  6897.     FSize.Highlight = BoxHeight/HighlightRows * 72
  6898.     FSize.Extras    = FSize.Highlight * MagnifyExtras
  6899.     FSize.Date      = BoxHeight/HighlightRows * 72 * StretchDateH
  6900.     Width.Date      = 100 * StretchDateW / StretchDateH
  6901.     FSize.Weekday   = (TextArea - MiniCalHeight) * WeekdaySize * 72
  6902.     FSize.Header    = TextArea * HeaderSize * 72
  6903.     FSize.SubHeader = TextArea * SubHeaderSize * 72
  6904.  
  6905.     if App == 'FW' then do
  6906.       FSize.MiniCal  = MiniCalHeight/6 * 72
  6907.       do i = 0 to FontTypes
  6908.         FSize.i = min(max(trunc(FSize.i), 4), 360)
  6909.         Width.i = min(max(trunc(Width.i), 4), 255)
  6910.       end
  6911.     end
  6912.     else if App == 'PGS' then FSize.MiniCal  = MiniCalHeight/7 * 72
  6913.  
  6914.     Height.Highlight = FSize.Highlight / 4 * Height.4pt * Leading/100
  6915.     Height.Date      = FSize.Date / 4 * Height.4pt * Leading/100
  6916.     Height.Weekday   = FSize.Weekday / 4 * Height.4pt * Leading/100
  6917.     Height.Header    = FSize.Header / 4 * Height.4pt * Leading/100
  6918.     Height.MiniCal   = FSize.MiniCal / 4 * Height.4pt * Leading/100
  6919.     Height.Extras    = FSize.Extras / 4 * Height.4pt * Leading/100
  6920.     Height.SubHeader = FSize.SubHeader / 4 * Height.4pt * Leading/100
  6921.  
  6922.     if DoMiniCals == 1 then call GetMiniMax(MiniCal)
  6923.   end
  6924.   else do
  6925.     Height.4pt     = GetHeight(4pt)
  6926.     MiniCalSpacing = MiniCalSpacing / 100
  6927.  
  6928.     if ((((PrintHeight - (3 * MiniCalSpacing) - Height.4pt) / 4 ) / 7) * 72) >= 4 then DoCopyright = 1
  6929.     else DoCopyright = 0
  6930.  
  6931.     MiniCalSpacing  = PrintWidth * MiniCalSpacing
  6932.     MiniCalWidth    = (PrintWidth - 2 * MiniCalSpacing)/3
  6933.     FSize.FYMiniCal = (((PrintHeight - (3 * MiniCalSpacing) - (Height.4pt * DoCopyright)) / 4 ) / 7) * 72
  6934.     if App == 'FW' then FSize.FYMiniCal = max(trunc(FSize.FYMiniCal), 4)
  6935.     Height.FYMiniCal = FSize.FYMiniCal / 4 * Height.4pt * Leading/100
  6936.     call GetMiniMax(FYMiniCal)
  6937.   end
  6938.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6939.  
  6940.   if App == 'FW' then do
  6941.     FIRSTOBJECT; ObjID = result
  6942.     SELECTOBJECT ObjID
  6943.     do forever
  6944.       NEXTOBJECT ObjID; ObjID = result
  6945.       if ObjID == 0 then leave
  6946.       SELECTOBJECT ObjID MULTIPLE
  6947.     end
  6948.     DELETEOBJECT
  6949.   end
  6950.   if UpdateBusy(Req, 1) == -1 then call Cleanup
  6951.   VariablesSet = 1
  6952.   if ErrorCount > 0 then call Cleanup
  6953.  
  6954.   return
  6955. /**/
  6956.  
  6957. /***//*** TranslationStrings () ***/
  6958. TranslationStrings:
  6959. Sunday$    = 'Sunday'
  6960. Monday$    = 'Monday'
  6961. Tuesday$   = 'Tuesday'
  6962. Wednesday$ = 'Wednesday'
  6963. Thursday$  = 'Thursday'
  6964. Friday$    = 'Friday'
  6965. Saturday$  = 'Saturday'
  6966.  
  6967. January$   = 'January'
  6968. February$  = 'February'
  6969. March$     = 'March'
  6970. April$     = 'April'
  6971. May$       = 'May'
  6972. June$      = 'June'
  6973. July$      = 'July'
  6974. August$    = 'August'
  6975. September$ = 'September'
  6976. October$   = 'October'
  6977. November$  = 'November'
  6978. December$  = 'December'
  6979.  
  6980. AddEvent$       = 'Add Event'
  6981. AddIC$          = '+IC'
  6982. All$            = 'All'
  6983. BiOrWeekly$     = '(Bi)Weekly'
  6984. Biweekly$       = 'Biweekly'
  6985. Bottom$         = 'Bottom'
  6986. BoxColor$       = 'Box'
  6987. BoxDates$       = 'Box Dates'
  6988. Boxed$          = '_Boxed'
  6989. Calendar$       = 'Calendar'
  6990. Calendars$      = 'Calendars'
  6991. Cancel$         = '_Cancel'
  6992. CantFind$       = "can't be found"
  6993. Center$         = 'Center'
  6994. Clear$          = 'Clear'
  6995. Color$          = 'Color'
  6996. Colors$         = 'Colors'
  6997. Comment$        = 'Comment'
  6998. Critical$       = 'Critical error'
  6999. DailyColors$    = 'Use daily colors'
  7000. DeleteEvent$    = 'Delete Event'
  7001. Done$           = 'Done'
  7002. Easter$         = 'Easter'
  7003. End$            = 'End'
  7004. EnterEvent$     = 'You must enter an event...'
  7005. EnterEventInfo$ = 'Enter event information'
  7006. EnterNewIC$     = 'Enter new ImageClass'
  7007. EnterStartdate$ = 'You must enter a start date...'
  7008. Even$           = 'Even'
  7009. Event$          = 'Event'
  7010. Extended$       = 'Extended'
  7011. File$           = 'File'
  7012. First$          = 'First'
  7013. Fixed$          = 'Fixed'
  7014. Floating$       = 'Floating'
  7015. Font$           = 'Font'
  7016. Fonts$          = 'Fonts'
  7017. ForDetails$     = 'for details'
  7018. ForwardContent$ = 'Forward contents of output to'
  7019. ForwardLog$     = 'Forward log file to'
  7020. Fourth$         = 'Fourth'
  7021. Frequency$      = 'Frequency'
  7022. GeneratingM$    = 'Generating %s %s calendar'
  7023. GeneratingY$    = 'Generating %s calendar'
  7024. Go$             = 'Go'
  7025. Header$         = '%s %s'
  7026. HighlightEd$    = 'Highlight Editor'
  7027. Highlights$     = 'Highlights'
  7028. History$        = 'History'
  7029. Holiday$        = 'Holiday'
  7030. Images$         = 'Images'
  7031. Julian$         = 'Julian'
  7032. JulJulLeft$     = 'Jul/Jul Left'
  7033. JulLeft$        = 'Jul Left'
  7034. Last$           = 'Last'
  7035. Left$           = 'Left'
  7036. Line$           = '_Line'
  7037. Load$           = '_Load'
  7038. MatchColors$    = 'Date Color = Highlight Color'
  7039. MiniCals$       = 'MiniCals'
  7040. MiscVar$        = 'Miscellaneous Variables'
  7041. MultiMonth$     = 'Multi-Month'
  7042. MustUse$        = 'You must use the gadget to'||'0a'x||'the right for this value.'
  7043. NextDay$        = 'Next day'
  7044. Noncritical$    = 'Noncritical warning'
  7045. None$           = 'None'
  7046. NotClear$       = '<'Clear$'> can only be used for "Background." variables...'
  7047. Note$           = 'Notes'
  7048. NoteBox$        = 'Note box'
  7049. Notice$         = 'notice'
  7050. Odd$            = 'Odd'
  7051. OK$             = '_OK'
  7052. OK2$            = 'OK'
  7053. Once$           = 'Once'
  7054. Options$        = 'Options'
  7055. OptLayout$      = 'Options & Layout'
  7056. OrientMarg$     = 'Orientation & Margins'
  7057. Phases$         = 'Phases'
  7058. PleaseWait$     = 'please wait'
  7059. PrepReq$        = 'Preparing requester'
  7060. PreviousDay$    = 'Prev day'
  7061. ProcessEvents$  = 'Processing events'
  7062. Random$         = 'Random'
  7063. Reset$          = '_Reset'
  7064. Right$          = 'Right'
  7065. RiseSet$        = 'Rise/Set'
  7066. SaveAs$         = '_Save as'
  7067. Second$         = 'Second'
  7068. See$            = 'see'
  7069. SeeOutput$      = 'see the output above for details'
  7070. SeeShell$       = 'see the shell output for details'
  7071. SelectApp$      = 'Select application'
  7072. SelectFile$     = 'Select data file'
  7073. SelectFont$     = 'Select font'
  7074. SelectImage$    = 'Select image'
  7075. SelectPrefs$    = 'Select name for prefs file'
  7076. SingleMonth$    = 'Single Month'
  7077. Start$          = 'Start'
  7078. SubHeader$      = ''
  7079. Sunrise$        = 'Sunrise'
  7080. Sunset$         = 'Sunset'
  7081. Tall$           = 'Tall'
  7082. TextColor$      = 'Text'
  7083. Third$          = 'Third'
  7084. Top$            = 'Top'
  7085. TopLong$        = 'Extra week at top'
  7086. Type$           = 'Type'
  7087. Unable$         = 'if you are unable to resolve the problem.'
  7088. VarGUITitle$    = 'Set desired variables'
  7089. Variables$      = 'Variables'
  7090. Weekend$        = 'Weekend'
  7091. Weekly$         = 'Weekly'
  7092. WeekNumber$     = 'Week Number'
  7093. WeekType$       = 'Week Type'
  7094. WholeYear$      = 'Whole Year'
  7095. Wide$           = 'Wide'
  7096.  
  7097. Help$                       = 'Help message'
  7098. Help$.ClickTabHelp          = 'Different tabs display*ndifferent variables'
  7099. Help$.MiniCalsGadHelp       = 'Include mini-calendars showing*nthe previous & next months'
  7100. Help$.HighlightsGadHelp     = 'Include highlights on*nthe generated calendar'
  7101. Help$.ImagesGadHelp         = 'Include images on*nthe generated calendar'
  7102. Help$.BoxDatesGadHelp       = 'Surround day numbers*nwith boxes'
  7103. Help$.ExtendedGadHelp       = 'Include days from the previous*nand next months on the*ngenerated calendar'
  7104. Help$.TopLongGadHelp        = 'Include days from the sixth week*nat the top of the calendar'
  7105. Help$.NoteBoxGadHelp        = 'Include an area to write notes*nwhere no dates are printed'
  7106. Help$.TopMargGadHelp        = "Set calendar's top margin*nRemember to <RETURN>"
  7107. Help$.LeftMargGadHelp       = "Set calendar's left margin*nRemember to <RETURN>"
  7108. Help$.OrientationGadHelp    = "Set calendar's orientation"
  7109. Help$.RightMargGadHelp      = "Set calendar's right margin*nRemember to <RETURN>"
  7110. Help$.BottomMargGadHelp     = "Set calendar's bottom margin*nRemember to <RETURN>"
  7111. Help$.FontVarGadHelp        = 'Select the font variable to set'
  7112. Help$.FontValGadHelp        = 'Displays the choosen font value'
  7113. Help$.ChooseFontGadHelp     = 'Select the desired font'
  7114. Help$.ColorVarGadHelp       = 'Select the color variable to set'
  7115. Help$.CycleColorVarGadHelp  = 'Cycle through the color variables*nShift to reverse cycle'
  7116. Help$.ColorValGadHelp       = 'Select the desired color'
  7117. Help$.MatchColorsGadHelp    = 'Use the highlight text color*nfor the date/date box'
  7118. Help$.DailyColorsGadHelp    = 'Use the Color.(Weekday) colors*nfor the date/date box'
  7119. Help$.HighlightEditGadHelp  = 'Bring up the*nHighlight Editor'
  7120. Help$.MiscVarGadHelp        = 'Select the desired*nmiscellaneous variable'
  7121. Help$.CycleMiscVarGadHelp   = 'Cycle through the miscellaneous variables*nShift to reverse cycle'
  7122. Help$.MiscValGadHelp        = 'Enter the desired variable value'
  7123. Help$.ChooseValGadHelp      = 'Used only for selecting files/paths'
  7124. Help$.AddImageClassGadHelp  = 'Add an ImageClass variable'
  7125. Help$.Extra3Help            = "Select extra to be printed*nin calendar's top-center"
  7126. Help$.Extra4Help            = "Select extra to be printed*nin calendar's top-right"
  7127. Help$.Extra0Help            = "Select extra to be printed*nin calendar's bottom-left"
  7128. Help$.Extra1Help            = "Select extra to be printed*nin calendar's bottom-center"
  7129. Help$.Extra2Help            = "Select extra to be printed*nin calendar's bottom-right"
  7130. Help$.CalendarTypeGadHelp   = 'Select calendar type'
  7131. Help$.EndMonthGadHelp       = 'Select desired end month'
  7132. Help$.StartMonthGadHelp     = 'Select desired start month'
  7133. Help$.MonthGadHelp          = 'Select desired month'
  7134. Help$.YearGadHelp           = 'Select or enter desired year'
  7135. Help$.GoGadHelp             = 'Begin generation of calendar'
  7136. Help$.ResetGadHelp          = 'Reset all variables to defaults'
  7137. Help$.LoadGadHelp           = 'Load a new preference file'
  7138. Help$.SaveAsGadHelp         = 'Save current settings to*na new preference file'
  7139. Help$.CancelGadHelp         = 'Cancel FWCalendar'
  7140. Help$.EH_EventGadHelp       = 'Enter the Highlight as it*nwill show up on calendar'
  7141. Help$.EH_ChooseEventGadHelp = 'Select Image file to be printed on calendar'
  7142. Help$.EH_ListEventGadHelp   = 'List all Highlights*nfor current month'
  7143. Help$.EH_CycleEventGadHelp  = 'Cycle through all Highlights*nfor current month'
  7144. Help$.EH_CommentGadHelp     = 'Enter optional comment'
  7145. Help$.EH_MonthGadHelp       = 'Select month to work with'
  7146. Help$.ExtraDHelp            = 'Select the date on*nwhich the Highlight falls'
  7147. Help$.LD                    = 'Indicates the Highlight always falls*non the last day of the month'
  7148. Help$.EH_ColorGadHelp       = 'Select color to be*nused for the Highlight'
  7149. Help$.EH_HLTypeGadHelp      = 'Select the Highlight type'
  7150. Help$.EH_WeekNumberGadHelp  = 'Select which week a floating*nHighlight occurs in'
  7151. Help$.EH_WeekTypeGadHelp    = 'Select frequency of weekly Highlights'
  7152. Help$.EH_WeekendGadHelp     = 'Determine whether or not the*nHighlight can fall on a weekend'
  7153. Help$.EH_HolidayGadHelp     = 'Treat the Highlight as a holiday'
  7154. Help$.EH_EasterGadHelp      = 'The number of days before or*nafter Easter for the Highlight'
  7155. Help$.EH_AddEventGadHelp    = 'Add a new Highlight'
  7156. Help$.EH_DeleteEventGadHelp = 'Delete the currently*ndisplayed Highlight'
  7157. Help$.EH_DoneGadHelp        = 'Save all changes to Highlights'
  7158. Help$.GE_EventTypeGadHelp   = 'Select to enter Event or*nuse an Event file'
  7159. Help$.GE_EventGadHelp       = 'Enter Event or display Event file'
  7160. Help$.GE_FontNameGadHelp    = 'Display font to be used'
  7161. Help$.GE_FontSizeGadHelp    = 'Enter font size to use'
  7162. Help$.GE_ChooseFontGadHelp  = 'Select font to be used'
  7163. Help$.GE_ResetGadHelp       = 'Reset font and font size'
  7164. Help$.GadIDHelp             = 'Enter Event start and end dates'
  7165. Help$.GE_StartGadHelp       = 'Display Event start date'
  7166. Help$.GE_EndGadHelp         = 'Display Event end date'
  7167. Help$.GE_TextColorGadHelp   = 'Select color to be*nused for Event text'
  7168. Help$.GE_LineGadHelp        = 'Select row on which*nEvent will be printed'
  7169. Help$.GE_BoxedGadHelp       = 'Surround Event with a box'
  7170. Help$.GE_BoxColorGadHelp    = 'Select color for box*nsurrounding Event'
  7171. Help$.GE_FrequencyGadHelp   = 'Select frequency of Event'
  7172. Help$.GE_OKGadHelp          = 'Use entered data to add*nEvent to calendar'
  7173. Help$.GE_CancelGadHelp      = 'Cancel FWCAddEvent'
  7174.  
  7175. return 0
  7176. /**/
  7177.  
  7178. /***//*** VarList () ***/
  7179. VarList:
  7180.   AddEventRows             = 9
  7181.   AdjustDST                = 1
  7182.   AltColor.Date            = Black$
  7183.   AltColor.Extended        = Black$
  7184.   AltColor.Highlight       = Black$
  7185.   AltColor.HighlightH      = Black$
  7186.   AltColor.History         = Black$
  7187.   AltColor.Julian          = Black$
  7188.   AltColor.Random          = Black$
  7189.   AltColor.Sunrise         = Black$
  7190.   AltColor.Sunset          = Black$
  7191.   AltColor.WeekNumber      = Black$
  7192.   Background.AddEvent      = White$
  7193.   Background.CalShadow     = Black$
  7194.   Background.Highlight     = '<'Clear$'>'
  7195.   Background.HighlightH    = '<'Clear$'>'
  7196.   Background.MiniCal       = White$
  7197.   Background.MiniCalShadow = Black$
  7198.   Background.NoteBox       = '<'Clear$'>'
  7199.   Background.Standard      = '<'Clear$'>'
  7200.   Background.Weekend       = '<'Clear$'>'
  7201.   BelzierFactor            = .55
  7202.   Bold.MiniCal             = DefaultBold
  7203.   Bold.FYMiniCal           = DefaultBold
  7204.   CalendarBorder           = 0
  7205.   CalendarShadow           = 0
  7206.   CenterHistory            = 1
  7207.   CenterMiniDates          = 1
  7208.   CenterRandom             = 1
  7209.   Color.Sunday             = Black$
  7210.   Color.Monday             = Black$
  7211.   Color.Tuesday            = Black$
  7212.   Color.Wednesday          = Black$
  7213.   Color.Thursday           = Black$
  7214.   Color.Friday             = Black$
  7215.   Color.Saturday           = Black$
  7216.   Color.AddEvent           = Black$
  7217.   Color.Date               = Black$
  7218.   Color.Extended           = Black$
  7219.   Color.Header             = Black$
  7220.   Color.Highlight          = Black$
  7221.   Color.HighlightH         = Black$
  7222.   Color.History            = Black$
  7223.   Color.Julian             = Black$
  7224.   Color.MiniCal            = Black$
  7225.   Color.Moon               = Black$
  7226.   Color.NoteBox            = Black$
  7227.   Color.Random             = Black$
  7228.   Color.SubHeader          = Black$
  7229.   Color.Sunrise            = Black$
  7230.   Color.Sunset             = Black$
  7231.   Color.Weekday            = Black$
  7232.   Color.WeekNumber         = Black$
  7233.   CornerRadius             = 0
  7234.   DateOffset               = 2
  7235.   DoDailyColors            = 0
  7236.   DoDateBox                = 0
  7237.   DoExtended               = 1
  7238.   DoHide                   = 0
  7239.   DoHighlights             = 0
  7240.   DoHistory                = ''
  7241.   DoImages                 = 0
  7242.   DoJulian                 = ''
  7243.   DoJulianLeft             = ''
  7244.   DoMatchColors            = 0
  7245.   DoMiniCals               = 1
  7246.   DoNoteBox                = 0
  7247.   DoPhases                 = ''
  7248.   DoRandom                 = ''
  7249.   DoSunRise                = ''
  7250.   DoSunSet                 = ''
  7251.   DoTopExtraWk             = 0
  7252.   DoWeekNumber             = ''
  7253.   EndWeek                  = -1
  7254.   FinalView                = 75
  7255.   Font.Date                = DefaultFont
  7256.   Font.Extras              = DefaultFont
  7257.   Font.Header              = DefaultFont
  7258.   Font.Highlight           = DefaultFont
  7259.   Font.MiniCal             = DefaultFont
  7260.   Font.FYMiniCal           = DefaultFont
  7261.   Font.Weekday             = DefaultFont
  7262.   Font.SubHeader           = DefaultFont
  7263.   ForceBGUI                = 0
  7264.   GenMVars                 = 'Month.Month EnteredYear'
  7265.   GenYVars                 = 'EnteredYear'
  7266.   GfxApp                   = 'Visage'
  7267.   GfxAppPath               = ''
  7268.   HeaderLoc                = 9
  7269.   HeaderSize               = 50
  7270.   Header$                  = '%s %s'
  7271.   HeaderVars               = 'Month.Month Year'
  7272.   HelpTime                 = 4
  7273.   HighlightRows            = 9
  7274.   HostScreen               = ''
  7275.   LaunchM                  = ''
  7276.   LaunchY                  = ''
  7277.   Leading                  = 100
  7278.   Line.AddEvent            = Black$
  7279.   Line.CalBorder           = Black$
  7280.   Line.Extended            = Black$
  7281.   Line.Grid                = Black$
  7282.   Line.MiniCal             = Black$
  7283.   Line.NoteBox             = Black$
  7284.   MagnifyExtras            = 100
  7285.   Margin.Bottom            = 0
  7286.   Margin.Left              = 0
  7287.   Margin.Right             = 0
  7288.   Margin.Top               = 0
  7289.   MinHistoryWidth          = 70
  7290.   MinRandomWidth           = 70
  7291.   MinWidth                 = 80
  7292.   MaxImgHeight             = 75
  7293.   MaxImgWidth              = 75
  7294.   MiniCalHeight            = 60
  7295.   MiniCalSpacing           = 0.5
  7296.   MiniCalWidth             = 200
  7297.   MoonRadius               = 10
  7298.   Orientation              = 'Wide'
  7299.   PrefsName                = 'Default'
  7300.   ShadowType               = 'P'
  7301.   ShiftLMini               = 0
  7302.   ShiftRMini               = 0
  7303.   StartWeek                = 0
  7304.   StretchDateH             = 100
  7305.   StretchDateW             = 100
  7306.   SubHeaderLoc             = 0
  7307.   SubHeaderSize            = 0
  7308.   SubHeader$               = ''
  7309.   SubHeaderVars            = ''
  7310.   SunCalcPath              = ''
  7311.   Text.Julian              = ''
  7312.   Text.Sunrise             = ''
  7313.   Text.Sunset              = ''
  7314.   Text.WeekNumber          = ''
  7315.   TextAdj                  = 77
  7316.   TTextArea                = 15
  7317.   WeekdaySize              = 50
  7318.   WTextArea                = 20
  7319. return
  7320. /**/
  7321.  
  7322.